ArtifactManager should check for non null artifact early

This commit is contained in:
Guillaume Nodet 2024-02-09 18:13:15 +01:00
parent 07b256ae03
commit fd825f9b20
1 changed files with 4 additions and 2 deletions

View File

@ -36,6 +36,8 @@ import org.apache.maven.api.services.ArtifactManager;
import org.apache.maven.project.MavenProject;
import org.eclipse.sisu.Typed;
import static org.apache.maven.internal.impl.Utils.nonNull;
@Named
@Typed
@SessionScoped
@ -54,7 +56,7 @@ public class DefaultArtifactManager implements ArtifactManager {
@Nonnull
@Override
public Optional<Path> getPath(@Nonnull Artifact artifact) {
String id = id(artifact);
String id = id(nonNull(artifact, "artifact"));
if (session.getMavenSession().getAllProjects() != null) {
for (MavenProject project : session.getMavenSession().getAllProjects()) {
if (id.equals(id(project.getArtifact()))
@ -75,7 +77,7 @@ public class DefaultArtifactManager implements ArtifactManager {
@Override
public void setPath(@Nonnull Artifact artifact, Path path) {
String id = id(artifact);
String id = id(nonNull(artifact, "artifact"));
if (session.getMavenSession().getAllProjects() != null) {
session.getMavenSession().getAllProjects().stream()
.flatMap(this::getProjectArtifacts)