-
Enhancement
-
Resolution: Fixed
-
P3
-
19
-
b14
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8298140 | 17.0.7-oracle | Adithya Haradi Gopal | P3 | Resolved | Fixed | b01 |
JDK-8301711 | 17.0.7 | Goetz Lindenmaier | P3 | Resolved | Fixed | b01 |
com/sun/jdi tests report errors by calling TestScaffold.failure(msg), which prints the failure message and sets the testFailed flag. At some later point the failure is detected and an exception is thrown. The end result is the exception has just has a vanilla message that says something like "TestXXX failed", and the backtrace is not indicative of where the failure occurred. If you have tools that search logs looking for exceptions to determine the reason for the failure, you likely won't find any. Here's an example:
[2ms] run args: [SuspendAfterDeathTarg]
[514ms] FAILED: got Breakpoint event before ThreadDeath event.
java.lang.Exception: SuspendAfterDeath: failed
at SuspendAfterDeath.runTests(SuspendAfterDeath.java:110)
at TestScaffold.startTests(TestScaffold.java:432)
at SuspendAfterDeath.main(SuspendAfterDeath.java:47)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:1589)
So the reason for the failure is clear (the "FAILED" message), but its stack trace is missing and the reason is not included in the exception message that is printed much later on. The fix for this is pretty simple:
protected void failure(String str) {
- println(str);
+ Exception ex = new Exception(str);
+ ex.printStackTrace(System.err);
testFailed = true;
}
And the end result in the log:
java.lang.Exception: FAILED: got Breakpoint event before ThreadDeath event.
at TestScaffold.failure(TestScaffold.java:455)
at SuspendAfterDeath.breakpointReached(SuspendAfterDeath.java:64)
at TestScaffold$EventHandler.notifyEvent(TestScaffold.java:194)
at TestScaffold$EventHandler.run(TestScaffold.java:278)
at java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.Exception: SuspendAfterDeath: failed
at SuspendAfterDeath.runTests(SuspendAfterDeath.java:110)
at TestScaffold.startTests(TestScaffold.java:433)
at SuspendAfterDeath.main(SuspendAfterDeath.java:47)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:1589)
So now instead of just a simple FAIL message, we have an exception message and a backtrace at the point of failure. Not only is this useful for someone looking at the log, but also for tools searching the log for a reason for the failure.
[2ms] run args: [SuspendAfterDeathTarg]
[514ms] FAILED: got Breakpoint event before ThreadDeath event.
java.lang.Exception: SuspendAfterDeath: failed
at SuspendAfterDeath.runTests(SuspendAfterDeath.java:110)
at TestScaffold.startTests(TestScaffold.java:432)
at SuspendAfterDeath.main(SuspendAfterDeath.java:47)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:1589)
So the reason for the failure is clear (the "FAILED" message), but its stack trace is missing and the reason is not included in the exception message that is printed much later on. The fix for this is pretty simple:
protected void failure(String str) {
- println(str);
+ Exception ex = new Exception(str);
+ ex.printStackTrace(System.err);
testFailed = true;
}
And the end result in the log:
java.lang.Exception: FAILED: got Breakpoint event before ThreadDeath event.
at TestScaffold.failure(TestScaffold.java:455)
at SuspendAfterDeath.breakpointReached(SuspendAfterDeath.java:64)
at TestScaffold$EventHandler.notifyEvent(TestScaffold.java:194)
at TestScaffold$EventHandler.run(TestScaffold.java:278)
at java.base/java.lang.Thread.run(Thread.java:1589)
java.lang.Exception: SuspendAfterDeath: failed
at SuspendAfterDeath.runTests(SuspendAfterDeath.java:110)
at TestScaffold.startTests(TestScaffold.java:433)
at SuspendAfterDeath.main(SuspendAfterDeath.java:47)
at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)
at java.base/java.lang.reflect.Method.invoke(Method.java:578)
at com.sun.javatest.regtest.agent.MainWrapper$MainThread.run(MainWrapper.java:127)
at java.base/java.lang.Thread.run(Thread.java:1589)
So now instead of just a simple FAIL message, we have an exception message and a backtrace at the point of failure. Not only is this useful for someone looking at the log, but also for tools searching the log for a reason for the failure.
- backported by
-
JDK-8298140 Improve com/sun/jdi/TestScaffold error reporting
-
- Resolved
-
-
JDK-8301711 Improve com/sun/jdi/TestScaffold error reporting
-
- Resolved
-
- links to
-
Commit openjdk/jdk17u-dev/012a216c
-
Commit openjdk/jdk/da99e3e8
-
Review openjdk/jdk17u-dev/1138
-
Review openjdk/jdk/10127
(1 links to)