diff --git a/WHATSNEW b/WHATSNEW index b73511bee..1ee9995b3 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -18,6 +18,9 @@ Fixed bugs: * fails with NPE when compiling with eclipse ecj 3.1.x. Bugzilla 40839. + +* JUnitTestRunner had a NPE when unable to create parser, the exception + containing the error did not get reported. Bugzilla 36733. Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java index 212a209eb..51d2f671b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner.java @@ -288,6 +288,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR Test suite = null; Throwable exception = null; + boolean startTestSuiteSuccess = false; try { @@ -368,6 +369,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR long start = System.currentTimeMillis(); fireStartTestSuite(); + startTestSuiteSuccess = true; if (exception != null) { // had an exception constructing suite for (int i = 0; i < formatters.size(); i++) { ((TestListener) formatters.elementAt(i)) @@ -405,8 +407,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR systemError = null; systemOut.close(); systemOut = null; - sendOutAndErr(new String(outStrm.toByteArray()), - new String(errStrm.toByteArray())); + if (startTestSuiteSuccess) { + sendOutAndErr(new String(outStrm.toByteArray()), + new String(errStrm.toByteArray())); + } } fireEndTestSuite();