You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2019/12/23 20:31:30 UTC

[GitHub] [logging-log4j2] carterkozak commented on a change in pull request #324: LOG4J2-2415 - Lock contention in classloader because of missing org.slf4j.ext.EventData

carterkozak commented on a change in pull request #324: LOG4J2-2415 - Lock contention in classloader because of missing org.slf4j.ext.EventData
URL: https://github.com/apache/logging-log4j2/pull/324#discussion_r360995202
 
 

 ##########
 File path: log4j-slf4j-impl/src/main/java/org/apache/logging/slf4j/Log4jLogger.java
 ##########
 @@ -411,13 +411,17 @@ private void writeObject(final ObjectOutputStream aOutputStream) throws IOExcept
         aOutputStream.defaultWriteObject();
     }
 
+    private static Boolean eventDataLoaded = null;
     private static EventDataConverter createConverter() {
-        try {
-            LoaderUtil.loadClass("org.slf4j.ext.EventData");
-            return new EventDataConverter();
-        } catch (final ClassNotFoundException cnfe) {
-            return null;
+        if (eventDataLoaded == null) {
+            try {
+                LoaderUtil.loadClass("org.slf4j.ext.EventData");
+                eventDataLoaded = true;
+            } catch (final ClassNotFoundException cnfe) {
+                eventDataLoaded = false;
+            }
         }
+        return eventDataLoaded ? new EventDataConverter() : null;
 
 Review comment:
   Instead of modifying this method, what if we update the `converter` field to be static and call this method on class initialization? That way instead of requiring work (and allocation!) every time a logger is created, it's done once when the application loads.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services