ImmutableCollections.ROProperties loses Properties defaults chain
Found in: maven-4.0.x branch
File: api/maven-api-xml/src/main/java/org/apache/maven/api/xml/ImmutableCollections.java (lines ~168-176)
Severity: Medium
Description
ROProperties constructor calls super() (equivalent to Properties()) instead of preserving the parent defaults chain:
private ROProperties(Properties props) {
super(); // calls Properties() which sets defaults=null
if (props != null) {
for (Map.Entry<Object, Object> e : props.entrySet()) {
super.put(e.getKey(), e.getValue());
}
}
}
java.util.Properties has a defaults field that stores fallback properties. By calling super() instead of super(props != null ? props.defaults : null), the defaults chain is discarded. If props was created as new Properties(defaultsProps) where defaultsProps had key "foo"="bar", after wrapping in ROProperties, getProperty("foo") would return null instead of "bar".
ImmutableCollections.ROProperties loses Properties defaults chain
Found in: maven-4.0.x branch
File:
api/maven-api-xml/src/main/java/org/apache/maven/api/xml/ImmutableCollections.java(lines ~168-176)Severity: Medium
Description
ROPropertiesconstructor callssuper()(equivalent toProperties()) instead of preserving the parentdefaultschain:java.util.Propertieshas adefaultsfield that stores fallback properties. By callingsuper()instead ofsuper(props != null ? props.defaults : null), thedefaultschain is discarded. Ifpropswas created asnew Properties(defaultsProps)wheredefaultsPropshad key"foo"="bar", after wrapping inROProperties,getProperty("foo")would returnnullinstead of"bar".