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


##########
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.
   
   Right. That is a very subtle design detail. In particular, now we deviate 
from the existing practice, i.e., making all stuff public. Would you mind 
(preferably) in detail explaining this in the comments, please? I can imagine 
it can be very obvious to you, but I can assure you certainly not to the rest 
of the maintainers.



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