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

Avoid possible NPE, fixes #795 #806

Merged
merged 1 commit into from
Mar 10, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

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;
Expand Down Expand Up @@ -58,13 +59,22 @@ public void afterProjectExecutionSuccess(ProjectExecutionEvent projectExecutionE
@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
Expand Down