[ https://issues.apache.org/jira/browse/LOG4J2-1457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15371040#comment-15371040 ]
Leon Finker commented on LOG4J2-1457: ------------------------------------- Proposing only the following changes. Basically, add an argument to Loader.initializeClass(...boolean initialize...). And call it with false from ThrowableProxy use case. All tests succeed. {noformat} .../src/main/java/org/apache/logging/log4j/core/util/Loader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git c/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java w/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java index bb35752..5670f63 100644 --- c/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java +++ w/log4j-core/src/main/java/org/apache/logging/log4j/core/util/Loader.java @@ -236,9 +236,9 @@ public final class Loader { * @return The class. * @throws ClassNotFoundException if the class could not be found. */ - public static Class<?> initializeClass(final String className, final ClassLoader loader) + public static Class<?> initializeClass(final String className, boolean initialize, final ClassLoader loader) throws ClassNotFoundException { - return Class.forName(className, true, loader); + return Class.forName(className, initialize, loader); } /** {noformat} {noformat} .../org/apache/logging/log4j/core/config/AbstractConfiguration.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git c/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java w/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java index a152ea7..6acf3b8 100644 --- c/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java +++ w/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AbstractConfiguration.java @@ -207,7 +207,7 @@ public abstract class AbstractConfiguration extends AbstractFilterable implement for (final PluginType<?> type : plugins.values()) { try { // Cause the class to be initialized if it isn't already. - Loader.initializeClass(type.getPluginClass().getName(), type.getPluginClass().getClassLoader()); + Loader.initializeClass(type.getPluginClass().getName(), true, type.getPluginClass().getClassLoader()); } catch (final Exception e) { LOGGER.error("Unable to initialize {} due to {}", type.getPluginClass().getName(), e.getClass() .getSimpleName(), e); {noformat} {noformat} .../main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git c/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java w/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java index 28f8e56..6133d7a 100644 --- c/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java +++ w/log4j-core/src/main/java/org/apache/logging/log4j/core/impl/ThrowableProxy.java @@ -484,7 +484,7 @@ public class ThrowableProxy implements Serializable { Class<?> clazz; if (lastLoader != null) { try { - clazz = Loader.initializeClass(className, lastLoader); + clazz = Loader.initializeClass(className, false, lastLoader); if (clazz != null) { return clazz; } @@ -504,7 +504,7 @@ public class ThrowableProxy implements Serializable { private Class<?> initializeClass(final String className) { try { - return Loader.initializeClass(className, this.getClass().getClassLoader()); + return Loader.initializeClass(className, false, this.getClass().getClassLoader()); } catch (final ClassNotFoundException ignore) { return null; } catch (final NoClassDefFoundError ignore) { {noformat} > Class loader deadlock when using async logging > ---------------------------------------------- > > Key: LOG4J2-1457 > URL: https://issues.apache.org/jira/browse/LOG4J2-1457 > Project: Log4j 2 > Issue Type: Bug > Affects Versions: 2.6.1 > Environment: On CentOS 6.7 and Java 1.8.0_60. > Reporter: Leon Finker > Priority: Critical > Attachments: threaddump.txt > > > We've encountered a class loading deadlock. Please review attached thread > dump. Is it possible to have an option of pre-initializing the exception's > thread stack on the caller's thread? It's hard to predict what libraries are > doing in their classes' static initializers and may eventually end up logging > and causing deadlock. > In the attached thread dump here are the threads of interest: > "Log4j2-AsyncLogger[AsyncContext@18b4aac2]1" #16 daemon prio=5 os_prio=0 > tid=0x00007ff870c7b000 nid=0x79f3 in Object.wait() [0x00007ff839142000] > java.lang.Thread.State: RUNNABLE > at java.lang.Class.forName0(Native Method) > ... > and > "1A03340:Company:japan" #568 prio=5 os_prio=0 tid=0x00007ff871677000 > nid=0x725 runnable [0x00007ff74bd27000] > ...<clinit>... -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: log4j-dev-unsubscr...@logging.apache.org For additional commands, e-mail: log4j-dev-h...@logging.apache.org