elharo opened a new issue, #12584:
URL: https://github.com/apache/maven/issues/12584

   # SoftIdentityMap uses equals() instead of identity (==) comparison
   
   **Found in:** maven-4.0.x branch
   **File:** 
`impl/maven-impl/src/main/java/org/apache/maven/impl/SoftIdentityMap.java` 
(lines 53-63)
   **Severity:** Critical
   
   ## Description
   
   Despite the class name indicating identity-based (`==`) key comparison, 
`SoftIdentityReference.equals()` uses `thisRef.equals(otherRef)` (structural 
equality) instead of `thisRef == otherRef`. The hashCode also uses 
`referent.hashCode()` instead of `System.identityHashCode()`.
   
   ```java
   public boolean equals(Object obj) {
       ...
       T thisRef = this.get();
       Object otherRef = other.get();
       return thisRef != null && thisRef.equals(otherRef);  // should be ==
   }
   ```
   
   This defeats the purpose of an identity map: two distinct key objects that 
are structurally equal will collide and be treated as the same entry, causing 
incorrect cache hits in `DefaultRequestCache.doCache()` where `SoftIdentityMap` 
is used.


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