slinkydeveloper opened a new issue, #2098: URL: https://github.com/apache/logging-log4j2/issues/2098
## Description I'm using logj2 with a custom `ContextDataProvider`, and then using the [aws lambda appender](https://docs.aws.amazon.com/lambda/latest/dg/java-logging.html#java-logging-log4j2). My `ContextDataProvider` implementation uses `Map.of` methods from JDK to create cheap immutable maps, but apparently that doesn't work and throws UOE. In the stacktrace it's shown that a method down the stack invokes `ImmutableCollections.AbstractImmutableMap::clear`, which throws UOE. Interesting enough, in many online examples they use `Collections.emptyMap()` for the empty map, which doesn't throw UOE on `clear`. What puzzles me though is that I wasn't able to reproduce this issue with the log4j2-core console appender. Is the amazon appender doing something strange, or is this a bug of log4j2-core? ## Configuration **Version:** 2.22.0 **Operating system:** Linux **JDK:** 21 (amazon) ## Logs ``` 2023-12-15T11:26:15.337000+00:00 WARN StatusConsoleListener org.apache.logging.log4j.spi.AbstractLogger caught java.lang.UnsupportedOperationException logging ReusableSimpleMessage: Incremented counter! 2023-12-15T11:26:15.338000+00:00 java.lang.UnsupportedOperationException 2023-12-15T11:26:15.338000+00:00 at java.base/java.util.ImmutableCollections.uoe(Unknown Source) 2023-12-15T11:26:15.338000+00:00 at java.base/java.util.ImmutableCollections$AbstractImmutableMap.clear(Unknown Source) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.core.impl.JdkMapAdapterStringMap.clear(JdkMapAdapterStringMap.java:122) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.core.impl.MutableLogEvent.clear(MutableLogEvent.java:143) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.core.impl.ReusableLogEventFactory.release(ReusableLogEventFactory.java:141) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.core.config.LoggerConfig.log(LoggerConfig.java:578) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.core.config.AwaitCompletionReliabilityStrategy.log(AwaitCompletionReliabilityStrategy.java:92) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.core.Logger.log(Logger.java:169) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.spi.AbstractLogger.tryLogMessage(AbstractLogger.java:2933) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.spi.AbstractLogger.logMessageTrackRecursion(AbstractLogger.java:2886) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.spi.AbstractLogger.logMessageSafely(AbstractLogger.java:2868) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.spi.AbstractLogger.logMessage(AbstractLogger.java:2647) 2023-12-15T11:26:15.338000+00:00 at org.apache.logging.log4j.spi.AbstractLogger.logIfEnabled(AbstractLogger.java:2594) 2023-12-15T11:26:15.339000+00:00 at org.apache.logging.log4j.spi.AbstractLogger.info(AbstractLogger.java:1597) 2023-12-15T11:26:15.339000+00:00 at dev.restate.sdk.examples.Greeter.greet(Greeter.kt:31) [... My application stacktrace ...] 2023-12-15T11:26:15.340000+00:00 at dev.restate.sdk.lambda.BaseRestateLambdaHandler.handleRequest(BaseRestateLambdaHandler.java:28) 2023-12-15T11:26:15.340000+00:00 at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$PojoHandlerAsStreamHandler.handleRequest(EventHandlerLoader.java:202) 2023-12-15T11:26:15.340000+00:00 at com.amazonaws.services.lambda.runtime.api.client.EventHandlerLoader$2.call(EventHandlerLoader.java:905) 2023-12-15T11:26:15.340000+00:00 at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:245) 2023-12-15T11:26:15.340000+00:00 at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.startRuntime(AWSLambda.java:197) 2023-12-15T11:26:15.340000+00:00 at com.amazonaws.services.lambda.runtime.api.client.AWSLambda.main(AWSLambda.java:187) ``` -- 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]
