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
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.
Bug Description
WarUtils.isRelated()atsrc/main/java/org/apache/maven/plugins/war/util/WarUtils.javalines 69-80 has inverted equality checks. The method returnsfalsewhenversion,type,classifier, orscopeare equal between the artifact and the dependency — the opposite of what's intended.The method should return
falseonly when these attributes differ. As written, the method only returnstrueif every one of these four attributes differs while groupId/artifactId match.Impact
This makes
registerTargetFileName()inWebappStructureeffectively 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
Expected behavior
Each
ifblock should use!Objects.equals(...)so thatfalseis returned only when the values differ.