From ecfe2c42cab678c0fa6e4c4fcc9fd6523c5a53a5 Mon Sep 17 00:00:00 2001 From: Patrick Ziegler Date: Fri, 13 Feb 2026 19:52:15 +0100 Subject: [PATCH] Fix potential NPE in EnumPropertyEditor When an unknown property is selected, a `null` text is returned. Because the SWT combo doesn't support `null` strings, an exception might be thrown. Instead, an empty string has to be returned. Follow-up on 6ee0cd89442090296846298add13aa9585cd5a08 --- .../model/property/editor/AbstractEnumPropertyEditor.java | 2 +- .../core/model/property/editor/EnumPropertyEditorTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/AbstractEnumPropertyEditor.java b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/AbstractEnumPropertyEditor.java index 24a35302b..54d8d02d6 100644 --- a/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/AbstractEnumPropertyEditor.java +++ b/org.eclipse.wb.core.java/src/org/eclipse/wb/internal/core/model/property/editor/AbstractEnumPropertyEditor.java @@ -44,7 +44,7 @@ public String getText(Property property) throws Exception { return element.toString(); } // unknown value - return null; + return ""; } @Override diff --git a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/EnumPropertyEditorTest.java b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/EnumPropertyEditorTest.java index 0fe6b7a58..31414d1f0 100644 --- a/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/EnumPropertyEditorTest.java +++ b/org.eclipse.wb.tests/src/org/eclipse/wb/tests/designer/core/model/property/editor/EnumPropertyEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2024 Google, Inc. and others. + * Copyright (c) 2011, 2026 Google, Inc. and others. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at @@ -96,7 +96,7 @@ public void test_getText_noValue() throws Exception { GenericProperty property = (GenericProperty) panel.getPropertyByTitle("foo"); EnumPropertyEditor editor = (EnumPropertyEditor) property.getEditor(); // text - assertNull(editor.getText(property)); + assertEquals("", editor.getText(property)); assertNull(editor.getClipboardSource(property)); }