[
https://issues.apache.org/jira/browse/LOG4J2-1457?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15370154#comment-15370154
]
Leon Finker commented on LOG4J2-1457:
-------------------------------------
Hi Gary,
With the change, all tests succeed except one:
org.apache.logging.log4j.core.ExtendedLevelTest (the levels are part of c;ass
static initializer that must run).
{noformat}
Expected: a collection with size <1>
but: collection size was <0>
at
org.apache.logging.log4j.core.ExtendedLevelTest.testLevelLogging(ExtendedLevelTest.java:58).testLevelLogging:58
{noformat}
It's because Loader.initializeClass is also called as part of configuration
initialization for example. In that case we do want to run the class static
initializer. We only don't want to run it when extended stack is being created
for logging (of user classes).
So in this case we do want to run static initializer:
{noformat}
org.apache.logging.log4j.core.util.Loader.initializeClass(java.lang.String,
java.lang.ClassLoader) line: 241
org.apache.logging.log4j.core.config.xml.XmlConfiguration(org.apache.logging.log4j.core.config.AbstractConfiguration).initialize()
line: 210
org.apache.logging.log4j.core.config.xml.XmlConfiguration(org.apache.logging.log4j.core.config.AbstractConfiguration).start()
line: 231
org.apache.logging.log4j.core.LoggerContext.setConfiguration(org.apache.logging.log4j.core.config.Configuration)
line: 496
org.apache.logging.log4j.core.LoggerContext.start(org.apache.logging.log4j.core.config.Configuration)
line: 249
org.apache.logging.log4j.core.impl.Log4jContextFactory.getContext(java.lang.String,
java.lang.ClassLoader, java.lang.Object, boolean, java.net.URI,
java.lang.String) line: 239
org.apache.logging.log4j.core.config.Configurator.initialize(java.lang.String,
java.lang.ClassLoader, java.net.URI, java.lang.Object) line: 157
org.apache.logging.log4j.core.config.Configurator.initialize(java.lang.String,
java.lang.ClassLoader, java.lang.String, java.lang.Object) line: 130
org.apache.logging.log4j.core.config.Configurator.initialize(java.lang.String,
java.lang.ClassLoader, java.lang.String) line: 100
org.apache.logging.log4j.junit.LoggerContextRule$1.evaluate() line: 92
org.junit.rules.RunRules.evaluate() line: 20
{noformat}
But in this case must not run the static initializer of user classes that are
part of the exceptions:
"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
{noformat}
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:348)
at
org.apache.logging.log4j.core.util.Loader.initializeClass(Loader.java:241)
at
org.apache.logging.log4j.core.impl.ThrowableProxy.loadClass(ThrowableProxy.java:487)
at
org.apache.logging.log4j.core.impl.ThrowableProxy.toExtendedStackTrace(ThrowableProxy.java:617)
...
{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: [email protected]
For additional commands, e-mail: [email protected]