Adding a test for COLLECTIONS-299 and a fix. Fixes by not adding any non-String values as per java.util.Properties; also adding to the javadoc
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@711140 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
79ff10494b
commit
f3eaf2ceae
|
@ -1708,6 +1708,10 @@ public class ExtendedProperties extends Hashtable {
|
|||
* <p>
|
||||
* NOTE: From Commons Collections 3.2 this method will pick up
|
||||
* any default parent Properties of the specified input object.
|
||||
* <p>
|
||||
* 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;
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue