Pankraz76 commented on code in PR #2458:
URL: https://github.com/apache/maven/pull/2458#discussion_r2134737851


##########
impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java:
##########
@@ -877,16 +879,11 @@ public void setArtifacts(Set<Artifact> artifacts) {
      */
     public Set<Artifact> getArtifacts() {
         if (artifacts == null) {
-            if (artifactFilter == null || resolvedArtifacts == null) {
-                artifacts = new LinkedHashSet<>();
-            } else {
-                artifacts = new LinkedHashSet<>(resolvedArtifacts.size() * 2);
-                for (Artifact artifact : resolvedArtifacts) {
-                    if (artifactFilter.include(artifact)) {
-                        artifacts.add(artifact);

Review Comment:
   this the only on calling `.add()`.
   
   ```console
   Caused by: java.lang.NullPointerException: Cannot invoke 
"java.util.Set.add(Object)" because "this.artifacts" is null
       at org.apache.maven.project.MavenProject.getArtifacts 
(MavenProject.java:683)
       at org.apache.maven.project.MavenProject.getArtifactMap 
(MavenProject.java:693)
   ```
   
   its strange. need some software archaeologists to investigate.
   
   in the meanwhile, lets have `null save function`al style. this will 
hopefully avoid the issue, as not coupling/referencing triggering `NPE`.
   
   @elharo 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to