elharo opened a new issue, #619:
URL: https://github.com/apache/maven-war-plugin/issues/619

   ## Bug Description
   
   `WarUtils.isRelated()` at 
`src/main/java/org/apache/maven/plugins/war/util/WarUtils.java` lines 69-80 has 
inverted equality checks. The method returns `false` when `version`, `type`, 
`classifier`, or `scope` are **equal** between the artifact and the dependency 
— the opposite of what's intended.
   
   The method should return `false` only when these attributes **differ**. As 
written, the method only returns `true` if every one of these four attributes 
differs while groupId/artifactId match.
   
   ## Impact
   
   This makes `registerTargetFileName()` in `WebappStructure` effectively 
broken: a dependency will never match its artifact when any of these attributes 
coincide, and could match the wrong dependency when they all differ.
   
   ## Code
   
   ```java
   if (Objects.equals(artifact.getVersion(), dependency.getVersion())) {
       return false;  // BUG: should return false when NOT equal
   }
   if (Objects.equals(artifact.getType(), dependency.getType())) {
       return false;
   }
   if (Objects.equals(artifact.getClassifier(), dependency.getClassifier())) {
       return false;
   }
   if (Objects.equals(artifact.getScope(), dependency.getScope())) {
       return false;
   }
   ```
   
   ## Expected behavior
   
   Each `if` block should use `!Objects.equals(...)` so that `false` is 
returned only when the values differ.


-- 
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