logging-log4j-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gary Gregory (JIRA)" <j...@apache.org>
Subject [jira] [Created] (LOG4J2-1046) Circular Exception cause throws StackOverflowError
Date Tue, 09 Jun 2015 01:40:00 GMT
Gary Gregory created LOG4J2-1046:
------------------------------------

             Summary: Circular Exception cause throws StackOverflowError
                 Key: LOG4J2-1046
                 URL: https://issues.apache.org/jira/browse/LOG4J2-1046
             Project: Log4j 2
          Issue Type: Bug
    Affects Versions: 2.1, 2.3
            Reporter: Kenneth Gendron


If an exception with a circular-referenced exception (suppressed, or otherwise) is logged,
log4j will throw a StackOverflowError:
{code:java}
Exception e1 = new Exception();
Exception e2 = new Exception();
e2.addSuppressed(e1);
e1.addSuppressed(e2);
LoggerFactory.getLogger("root").error("Error", e1);
{code}

Will throw the following:
{code:java}
Exception in thread "main" java.lang.StackOverflowError
	at java.util.HashMap.hash(HashMap.java:338)
	at java.util.HashMap.get(HashMap.java:556)
	at java.lang.ClassLoader.getPackage(ClassLoader.java:1608)
	at java.lang.Package.getPackage(Package.java:334)
	at java.lang.Class.getPackage(Class.java:783)
	at org.apache.logging.log4j.core.impl.ThrowableProxy.toCacheEntry(ThrowableProxy.java:495)
	at org.apache.logging.log4j.core.impl.ThrowableProxy.toExtendedStackTrace(ThrowableProxy.java:547)
	at org.apache.logging.log4j.core.impl.ThrowableProxy.<init>(ThrowableProxy.java:113)
	at org.apache.logging.log4j.core.impl.ThrowableProxy.toSuppressedProxies(ThrowableProxy.java:588)
	at org.apache.logging.log4j.core.impl.ThrowableProxy.<init>(ThrowableProxy.java:116)
	at org.apache.logging.log4j.core.impl.ThrowableProxy.toSuppressedProxies(ThrowableProxy.java:588)
{code}

A simple stack trace printout will produce the following:
{code:java}
java.lang.Exception
	at NewClass.main(NewClass.java:95)
	Suppressed: java.lang.Exception
		at NewClass.main(NewClass.java:96)
	[CIRCULAR REFERENCE:java.lang.Exception]
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Mime
View raw message