Bug Description
DependencyInfo.hashCode() at src/main/java/org/apache/maven/plugins/war/util/DependencyInfo.java lines 87-91 violates the equals/hashCode contract.
equals() (line 83) compares only the dependency field, but hashCode() (lines 87-91) incorporates both dependency and targetFileName.
Impact
Two DependencyInfo objects with the same dependency but different targetFileName will be equals() (return true) but produce different hash codes, violating the fundamental contract and causing incorrect behavior in HashMap, HashSet, or any hash-based collection.
Code
// equals() — line 83
return Objects.equals(dependency, that.dependency);
// hashCode() — lines 87-91
public int hashCode() {
int result;
result = (dependency != null ? dependency.hashCode() : 0);
result = 31 * result + (targetFileName != null ? targetFileName.hashCode() : 0);
return result;
}
Expected behavior
hashCode() should be consistent with equals() — either include only dependency in both, or include both dependency and targetFileName in both.
Bug Description
DependencyInfo.hashCode()atsrc/main/java/org/apache/maven/plugins/war/util/DependencyInfo.javalines 87-91 violates the equals/hashCode contract.equals()(line 83) compares only thedependencyfield, buthashCode()(lines 87-91) incorporates bothdependencyandtargetFileName.Impact
Two
DependencyInfoobjects with the samedependencybut differenttargetFileNamewill beequals()(returntrue) but produce different hash codes, violating the fundamental contract and causing incorrect behavior inHashMap,HashSet, or any hash-based collection.Code
Expected behavior
hashCode()should be consistent withequals()— either include onlydependencyin both, or include bothdependencyandtargetFileNamein both.