ppkarwasz commented on code in PR #2815:
URL: https://github.com/apache/logging-log4j2/pull/2815#discussion_r1711287978


##########
log4j-core/src/main/java/org/apache/logging/log4j/core/jackson/Initializers.java:
##########
@@ -62,33 +65,43 @@ void setupModule(
                             : ThrowableProxyWithoutStacktraceMixIn.class);
         }
     }
+    /**
+     * Used to set up {@link SetupContext} from different {@link 
SimpleModule}s.
+     * <p>
+     *     Serializes the context map as list of objects.
+     * </p>
+     */
+    static class SetupContextAsEntryListInitializer extends 
AbstractInitializer {
+
+        @Override
+        void setupModule(
+                final SetupContext context, final boolean includeStacktrace, 
final boolean stacktraceAsString) {
+            super.setupModule(context, includeStacktrace, stacktraceAsString);
+            // Prevents reflective JPMS access
+            // https://github.com/apache/logging-log4j2/issues/2814
+            context.addSerializers(new SimpleSerializers(singletonList(new 
ContextDataAsEntryListSerializer())));
+            context.addDeserializers(
+                    new SimpleDeserializers(singletonMap(StringMap.class, new 
ContextDataAsEntryListDeserializer())));

Review Comment:
   That one is a public class with a public constructor.
   I am not very eager to expose additional classes to the public API.
   
   **BTW**: I am pretty sure we don't need to deserialize JSON in Log4j Core. 
We do it in unit tests and `log4j-server` used it, but the rest should be happy 
with serialization alone.
   
   Unfortunately I don't think it is easy to remove the deserialization feature.



-- 
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]

Reply via email to