You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2023/03/10 07:47:40 UTC

[maven-mvnd] branch master updated: Avoid possible NPE, fixes #795 (#806)

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

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git


The following commit(s) were added to refs/heads/master by this push:
     new 2113d61b Avoid possible NPE, fixes #795 (#806)
2113d61b is described below

commit 2113d61baa95c6d08be7522acf82a8be268c85b2
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Fri Mar 10 08:47:33 2023 +0100

    Avoid possible NPE, fixes #795 (#806)
---
 .../mvnd/logging/smart/LoggingExecutionListener.java     | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/daemon/src/main/java/org/mvndaemon/mvnd/logging/smart/LoggingExecutionListener.java b/daemon/src/main/java/org/mvndaemon/mvnd/logging/smart/LoggingExecutionListener.java
index 3fe2a20a..eccd2ba7 100644
--- a/daemon/src/main/java/org/mvndaemon/mvnd/logging/smart/LoggingExecutionListener.java
+++ b/daemon/src/main/java/org/mvndaemon/mvnd/logging/smart/LoggingExecutionListener.java
@@ -23,6 +23,7 @@ import javax.inject.Singleton;
 
 import org.apache.maven.execution.ExecutionEvent;
 import org.apache.maven.execution.ExecutionListener;
+import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.MavenSession;
 import org.apache.maven.execution.ProjectExecutionEvent;
 import org.apache.maven.execution.ProjectExecutionListener;
@@ -58,13 +59,22 @@ public class LoggingExecutionListener implements ExecutionListener, ProjectExecu
     @Override
     public void afterProjectExecutionFailure(ProjectExecutionEvent projectExecutionEvent) {
         MavenSession session = projectExecutionEvent.getSession();
+        boolean halted;
+        // The ReactorBuildStatus is only available if the SmartBuilder is used
         ReactorBuildStatus status =
                 (ReactorBuildStatus) session.getRepositorySession().getData().get(ReactorBuildStatus.class);
+        if (status != null) {
+            halted = status.isHalted();
+        } else {
+            // assume sensible default
+            Throwable t = projectExecutionEvent.getCause();
+            halted = (t instanceof RuntimeException || !(t instanceof Exception))
+                    || !MavenExecutionRequest.REACTOR_FAIL_NEVER.equals(session.getReactorFailureBehavior())
+                            && !MavenExecutionRequest.REACTOR_FAIL_AT_END.equals(session.getReactorFailureBehavior());
+        }
         Throwable cause = projectExecutionEvent.getCause();
         buildEventListener.executionFailure(
-                projectExecutionEvent.getProject().getArtifactId(),
-                status.isHalted(),
-                cause != null ? cause.toString() : null);
+                projectExecutionEvent.getProject().getArtifactId(), halted, cause != null ? cause.toString() : null);
     }
 
     @Override