diff --git a/src/java/org/apache/commons/collections/ExtendedProperties.java b/src/java/org/apache/commons/collections/ExtendedProperties.java index 35245d58c..6b113707e 100644 --- a/src/java/org/apache/commons/collections/ExtendedProperties.java +++ b/src/java/org/apache/commons/collections/ExtendedProperties.java @@ -1708,6 +1708,10 @@ public class ExtendedProperties extends Hashtable { *
* NOTE: From Commons Collections 3.2 this method will pick up * any default parent Properties of the specified input object. + *
+ * As with java.util.Properties(Properties), any non-String + * values will not be passed on in the new ExtendedProperties + * object. * * @param props the properties object to convert * @return new ExtendedProperties created from props @@ -1717,7 +1721,10 @@ public class ExtendedProperties extends Hashtable { for (Enumeration e = props.propertyNames(); e.hasMoreElements();) { String s = (String) e.nextElement(); - c.setProperty(s, props.getProperty(s)); + String value = props.getProperty(s); + if(value != null) { + c.setProperty(s, value); + } } return c; diff --git a/src/test/org/apache/commons/collections/TestExtendedProperties.java b/src/test/org/apache/commons/collections/TestExtendedProperties.java index 07f5231b0..ba6e514e7 100644 --- a/src/test/org/apache/commons/collections/TestExtendedProperties.java +++ b/src/test/org/apache/commons/collections/TestExtendedProperties.java @@ -428,4 +428,20 @@ public class TestExtendedProperties extends TestCase { assertEquals(3, props.size()); } + public void testCollections299() { + Properties defaults = new Properties(); + defaults.put("objectTrue", Boolean.TRUE); + + Properties properties = new Properties(defaults); + properties.put("objectFalse", Boolean.FALSE); + + ExtendedProperties extended = ExtendedProperties.convertProperties(properties); + + assertNull(extended.getString("objectTrue")); + assertNull(extended.getString("objectFalse")); + + assertNull(extended.get("objectTrue")); + assertNull(extended.get("objectFalse")); + } + }