Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ThrowableError.stackTrace() result should include suppressed exceptions #399

Closed
dkarlinsky opened this issue Sep 2, 2021 · 0 comments · Fixed by #405
Closed

ThrowableError.stackTrace() result should include suppressed exceptions #399

dkarlinsky opened this issue Sep 2, 2021 · 0 comments · Fixed by #405

Comments

@dkarlinsky
Copy link
Contributor

dkarlinsky commented Sep 2, 2021

Is your feature request related to a problem? Please describe.

Java Agent implements its own "print stack trace" that ignores Throwable#suppressedExceptions

Feature Description

Add suppressed exception to the stack trace captured here

An example of what Throwable.prinstStackTrace() displays for a throwable with suppressed exceptions:

Throwable exception = new RuntimeException("kaboom!", new IllegalArgumentException("kaboom cause"));
exception.addSuppressed(new IllegalStateException("kaboom suppressed 1"));
exception.addSuppressed(new NullPointerException("kaboom suppressed 2"));
exception.printStackTrace()
java.lang.RuntimeException: kaboom!
	at REPL.$JShell$11.do_it$Aux($JShell$11.java:6)
	at REPL.$JShell$11.do_it$($JShell$11.java:11)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at jdk.jshell/jdk.jshell.execution.DirectExecutionControl.invoke(DirectExecutionControl.java:209)
	at jdk.jshell/jdk.jshell.execution.RemoteExecutionControl.invoke(RemoteExecutionControl.java:116)
	at jdk.jshell/jdk.jshell.execution.DirectExecutionControl.invoke(DirectExecutionControl.java:119)
	at jdk.jshell/jdk.jshell.execution.ExecutionControlForwarder.processCommand(ExecutionControlForwarder.java:144)
	at jdk.jshell/jdk.jshell.execution.ExecutionControlForwarder.commandLoop(ExecutionControlForwarder.java:262)
	at jdk.jshell/jdk.jshell.execution.Util.forwardExecutionControl(Util.java:76)
	at jdk.jshell/jdk.jshell.execution.Util.forwardExecutionControlAndIO(Util.java:137)
	at jdk.jshell/jdk.jshell.execution.RemoteExecutionControl.main(RemoteExecutionControl.java:70)
	Suppressed: java.lang.IllegalStateException: kaboom suppressed 1
		at REPL.$JShell$12.do_it$($JShell$12.java:5)
		... 12 more
	Suppressed: java.lang.NullPointerException: kaboom suppressed 2
		at REPL.$JShell$13.do_it$($JShell$13.java:5)
		... 12 more
Caused by: java.lang.IllegalArgumentException: kaboom cause
	... 14 more
	... 11 more

Describe Alternatives

???

Additional context

We are using ZIO which provides fiber traces (cross thread traces) attached to its errors, which are extremely useful in async code.
For interoperability with other JVM code, ZIO fiber traces are attached to regular throwables.
In the past versions they were added as an extra throwable in the cause chain. This is kind of a hack, and some times requires the use of reflection.
In the latest ZIO release this has been changed in favor of using suppressed exceptions.
This means that once we upgrade ZIO, we will stop seeing fiber traces in NewRelic errors.

Priority

Really Want

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant