vy commented on code in PR #2101:
URL: https://github.com/apache/logging-log4j2/pull/2101#discussion_r1429771343
##########
log4j-core/src/main/java/org/apache/logging/log4j/core/impl/JdkMapAdapterStringMap.java:
##########
@@ -52,6 +52,11 @@ public JdkMapAdapterStringMap() {
public JdkMapAdapterStringMap(final Map<String, String> map) {
this.map = Objects.requireNonNull(map, "map");
+ try {
+ map.replace(Strings.EMPTY, Strings.EMPTY, Strings.EMPTY);
+ } catch (final UnsupportedOperationException ignored) {
+ immutable = true;
+ }
Review Comment:
Why don't we simply do `this.map = new HashMap<>(map)`? Checking against
`Map#replace()` implies that `Map#replace()` is the only effect expected to be
used and a future change to this contract will cause similar issues again.
--
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]