ppkarwasz commented on issue #2238:
URL:
https://github.com/apache/logging-log4j2/issues/2238#issuecomment-1908748402
@jdgenerix,
After looking better at the code the native storage of
`DefaultThreadContextMap` is JDK's `Map`, so the only optimization possible is
to create an additional constructor to `JdkMapAdapterStringMap` that takes an
additional boolean `frozen` parameter.
The:
```java
final ReadOnlyThreadContextMap map =
ThreadContext.getThreadContextMap();
if (map instanceof ReadOnlyStringMap) {
return (ReadOnlyStringMap) map;
}
```
is also wrong (a `ReadOnlyThreadContextMap` is a factory of
`ReadOnlyStringMap` not a `ReadOnlyStringMap` itself) and should be:
```java
final ReadOnlyThreadContextMap map =
ThreadContext.getThreadContextMap();
if (map != null) {
return map.getReadOnlyContextData();
}
```
--
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]