Skip to content

Commit

Permalink
Fix a NullPointerException during integration tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
desruisseaux committed Sep 24, 2024
1 parent 476af11 commit ca20975
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public class MavenProject implements Cloneable {
@Nonnull
private List<Artifact> attachedArtifacts;

@Nonnull
@Nullable
private MavenProject executionProject;

/**
Expand Down Expand Up @@ -337,7 +337,6 @@ public MavenProject(org.apache.maven.api.model.Model model) {
public MavenProject(@Nonnull Model model) {
// Do not invoke `setModel(Model)` as escaping `this` is deprecated.
this.model = Objects.requireNonNull(model);
executionProject = this;

// Immutable collections.
pluginArtifacts = Set.of();
Expand Down Expand Up @@ -375,7 +374,7 @@ public MavenProject(@Nonnull MavenProject project) {
rootDirectory = project.getRootDirectory();
artifactFilter = project.artifactFilter; // This internal property has no getter.
parentArtifact = project.getParentArtifact();
executionProject = project.getExecutionProject();
executionProject = project.executionProject; // Intentionally avoid the getter.
releaseArtifactRepository = project.getReleaseArtifactRepository();
snapshotArtifactRepository = project.getSnapshotArtifactRepository();
artifact = project.getArtifact();
Expand Down Expand Up @@ -1255,12 +1254,13 @@ public Xpp3Dom getGoalConfiguration(
return dom;
}

@Nonnull
public MavenProject getExecutionProject() {
return executionProject;
return (executionProject == null ? this : executionProject);
}

public void setExecutionProject(MavenProject project) {
executionProject = Objects.requireNonNull(project);
public void setExecutionProject(@Nullable MavenProject project) {
executionProject = project;
}

@Nonnull
Expand Down

0 comments on commit ca20975

Please sign in to comment.