-
Bug
-
Resolution: Fixed
-
P4
-
8, 11, 12, 13
-
b04
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8252444 | 11.0.9 | Joe Darcy | P4 | Resolved | Fixed | b06 |
JDK-8252489 | openjdk8u272 | Joe Darcy | P4 | Resolved | Fixed | b06 |
A DESCRIPTION OF THE PROBLEM :
When printing the stack trace of an exception which has circular references, the text "[CIRCULAR REFERENCE:...]" is always indented with a single tab, ignoring the current indentation level. This can be confusing for suppressed exceptions as demonstrated in the provided code.
Note also that there is a space missing after the colon:
"[CIRCULAR REFERENCE:java.lang.Exception: first]"
And ideally this message should include the caption (e.g. "Suppressed: [CIRCULAR ...") as well. Currently it is ambiguous whether this line represents a suppressed exception of the enclosing exception, or the cause of a preceding suppressed exception.
---------- BEGIN SOURCE ----------
public class DejaVuStackTrace {
public static void main(String[] args) {
Exception first = new Exception("first");
Exception second = new Exception("second");
first.addSuppressed(second);
Exception third = new Exception("third");
second.addSuppressed(third);
Exception fourth = new Exception("fourth");
third.addSuppressed(fourth);
// Create circular reference
fourth.addSuppressed(first);
fourth.addSuppressed(new Exception("fifth"));
first.printStackTrace();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Suggested fix:
https://github.com/openjdk/jdk/blob/c5cc07bec63fd7cad3e052cef53a5b19a4978e40/src/java.base/share/classes/java/lang/Throwable.java#L696
Change the line to this:
s.println(prefix + caption + "[CIRCULAR REFERENCE: " + this + "]");
FREQUENCY : always
When printing the stack trace of an exception which has circular references, the text "[CIRCULAR REFERENCE:...]" is always indented with a single tab, ignoring the current indentation level. This can be confusing for suppressed exceptions as demonstrated in the provided code.
Note also that there is a space missing after the colon:
"[CIRCULAR REFERENCE:java.lang.Exception: first]"
And ideally this message should include the caption (e.g. "Suppressed: [CIRCULAR ...") as well. Currently it is ambiguous whether this line represents a suppressed exception of the enclosing exception, or the cause of a preceding suppressed exception.
---------- BEGIN SOURCE ----------
public class DejaVuStackTrace {
public static void main(String[] args) {
Exception first = new Exception("first");
Exception second = new Exception("second");
first.addSuppressed(second);
Exception third = new Exception("third");
second.addSuppressed(third);
Exception fourth = new Exception("fourth");
third.addSuppressed(fourth);
// Create circular reference
fourth.addSuppressed(first);
fourth.addSuppressed(new Exception("fifth"));
first.printStackTrace();
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Suggested fix:
https://github.com/openjdk/jdk/blob/c5cc07bec63fd7cad3e052cef53a5b19a4978e40/src/java.base/share/classes/java/lang/Throwable.java#L696
Change the line to this:
s.println(prefix + caption + "[CIRCULAR REFERENCE: " + this + "]");
FREQUENCY : always
- backported by
-
JDK-8252444 Circular reference in printed stack trace is not correctly indented & ambiguous
- Resolved
-
JDK-8252489 Circular reference in printed stack trace is not correctly indented & ambiguous
- Resolved
- relates to
-
JDK-6911258 Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
- Closed
-
JDK-6962571 Infinite loop in printing out Throwable stack traces with circular references
- Closed