elharo opened a new issue, #12602:
URL: https://github.com/apache/maven/issues/12602
# 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:
```java
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"`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]