gnodet commented on code in PR #1108:
URL: https://github.com/apache/maven/pull/1108#discussion_r1194719859


##########
maven-artifact/src/main/java/org/apache/maven/artifact/DefaultArtifact.java:
##########
@@ -314,7 +314,9 @@ public boolean equals(Object o) {
             return false;
         } else if (!a.getArtifactId().equals(artifactId)) {
             return false;
-        } else if (!a.getVersion().equals(version)) {
+        } else if (a.getVersion() != null && !a.getVersion().equals(version)) {
+            return false;
+        } else if (a.getVersion() == null && version != null) {

Review Comment:
   I would suggest rewriting the whole logic in a single statement:
   ```
       return Objects.equals(a.getGroupId(), this.groupId)
           && Objects.equals(a.getArtifactId(), this.artifactId)
           && Objects.equals(a.getVersion(), this.version)
           && Objects.equals(a.getType(), this.type)
           && Objects.equals(a.getClassifier(), this.classifier);
   ```
   and rewrite the `hashCode` in a similar fashion:
   ```
           return Objects.hash(groupId, artifactId, type, version, classifier);
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to