simpleqt opened a new pull request, #757:
URL: https://github.com/apache/commons-collections/pull/757
`OrderedProperties.entrySet()` returned a detached `LinkedHashSet` of
`AbstractMap.SimpleEntry` copies, so every mutating operation on the set or on
its entries silently left the map unchanged:
```java
OrderedProperties props = new OrderedProperties();
props.put("key1", "value1");
props.entrySet().iterator().next().setValue("updated"); // map still holds
"value1"
props.entrySet().remove(new AbstractMap.SimpleEntry<>("key1", "value1"));
// no effect
props.entrySet().clear(); // map still has key1
```
`Map.entrySet()` requires the returned set to be backed by the map, and this
class already returns backed views from `keySet()` and `values()`, so
`entrySet()` was the outlier. The javadoc of `OrderedProperties` also presents
it as a drop-in `Properties` replacement, where `entrySet()` is backed.
`entrySet()` now returns an `AbstractSet` view over the ordered keys whose
iterator wraps each key in a `TiedMapEntry`, so `setValue` writes through to
the map and `Iterator.remove()` removes the mapping. `clear()`, `size()` and
`contains()` follow the map. No public signature changes.
## Test
`OrderedPropertiesTest` gained the three `entrySet()` removals in the
existing view-removal parameterized test, and a regression test for `setValue`
and iterator removal.
- with the source change reverted: `mvn -B -o -ntp
-Dtest=OrderedPropertiesTest test` -> 28 run, 4 failures (`expected: <updated>
but was: <value1>` and three `expected: <false> but was: <true>`)
- with the change: same command -> 28 run, 0 failures; full module `mvn -B
-o -ntp test` -> 22,549 run, 0 failures, 0 errors, 82 skipped
The commit carries an `Assisted-By:` trailer and a `src/changes/changes.xml`
action.
--
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]