This is an automated email from the ASF dual-hosted git repository. matthiasblaesing pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
commit bbef6872aec72e878a3238191dc83eff53a67c64 Author: Matthias Bläsing <[email protected]> AuthorDate: Sun Nov 12 21:29:17 2017 +0100 #270913: Prevent PropertiesEditor from being set to a non Propeties value (apart from NULL) --- .../org/netbeans/modules/db/util/PropertiesEditor.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/db/src/org/netbeans/modules/db/util/PropertiesEditor.java b/db/src/org/netbeans/modules/db/util/PropertiesEditor.java index d7be90f..a75c3be 100644 --- a/db/src/org/netbeans/modules/db/util/PropertiesEditor.java +++ b/db/src/org/netbeans/modules/db/util/PropertiesEditor.java @@ -23,6 +23,8 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyEditorSupport; import java.util.Properties; +import java.util.logging.Level; +import java.util.logging.Logger; import org.openide.explorer.propertysheet.ExPropertyEditor; import org.openide.explorer.propertysheet.PropertyEnv; import org.openide.nodes.Node; @@ -35,12 +37,14 @@ import org.openide.util.NbBundle; */ public class PropertiesEditor extends PropertyEditorSupport implements ExPropertyEditor { + private static final Logger LOG = Logger.getLogger(PropertiesEditor.class.getName()); + private boolean canWrite = true; @Override public String getAsText() { Properties value = (Properties) getValue(); - if (value == null || value.size() == 0) { + if (value == null || value.isEmpty()) { return NbBundle.getMessage(PropertiesEditor.class, "NoPropertiesSet"); //NOI18N } else { @@ -48,6 +52,16 @@ public class PropertiesEditor extends PropertyEditorSupport implements ExPropert } } + @Override + public void setValue(Object value) { + if(value == null || value instanceof Properties) { + super.setValue(value); + } else { + super.setValue(null); + LOG.log(Level.INFO, "Illegal value supplied to PropertiesEditor#setValue: {0}", value.getClass().getName()); + } + } + /** * Can't be called and throws IllegalArgumentException */ -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
