Details
-
Bug
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
2.1, 2.3
-
None
-
None
-
None
Description
If an exception with a circular-referenced exception (suppressed, or otherwise) is logged, log4j will throw a StackOverflowError:
Exception e1 = new Exception(); Exception e2 = new Exception(); e2.addSuppressed(e1); e1.addSuppressed(e2); LoggerFactory.getLogger("root").error("Error", e1);
Will throw the following:
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)
A simple stack trace printout will produce the following:
java.lang.Exception at NewClass.main(NewClass.java:95) Suppressed: java.lang.Exception at NewClass.main(NewClass.java:96) [CIRCULAR REFERENCE:java.lang.Exception]
Attachments
Issue Links
- is cloned by
-
LOG4J2-1046 Circular Exception cause throws StackOverflowError
-
- Closed
-