You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/03/09 20:28:32 UTC

[maven-surefire] 01/01: [SUREFIRE-2001] Sometimes the plugin prints an internal stack trace on BUILD FAILURE

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch SUREFIRE-2001
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 8897362f641091b8990db6b7bc6bd29064979897
Author: tibordigana <ti...@apache.org>
AuthorDate: Wed Mar 9 21:28:12 2022 +0100

    [SUREFIRE-2001] Sometimes the plugin prints an internal stack trace on BUILD FAILURE
---
 .../java/org/apache/maven/plugin/surefire/SurefireHelper.java | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
index 1870223..b64f436 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/SurefireHelper.java
@@ -265,15 +265,18 @@ public final class SurefireHelper
                                            Exception firstForkException )
             throws MojoFailureException, MojoExecutionException
     {
+        String msg = createErrorMessage( reportParameters, result, firstForkException );
         if ( isFatal( firstForkException ) || result.isInternalError()  )
         {
-            throw new MojoExecutionException( createErrorMessage( reportParameters, result, firstForkException ),
-                                                    firstForkException );
+            throw firstForkException == null
+                ? new MojoExecutionException( msg )
+                : new MojoExecutionException( msg, firstForkException );
         }
         else
         {
-            throw new MojoFailureException( createErrorMessage( reportParameters, result, firstForkException ),
-                                                  firstForkException );
+            throw firstForkException == null
+                ? new MojoFailureException( msg )
+                : new MojoFailureException( msg, firstForkException );
         }
     }