coheigea commented on code in PR #3604:
URL: https://github.com/apache/cxf/pull/3604#discussion_r4314056823


##########
core/src/main/java/org/apache/cxf/common/util/WeakIdentityHashMap.java:
##########
@@ -95,7 +96,8 @@ public V setValue(V value) {
     }
     public Set<K> keySet() {
         reap();
-        Set<K> ret = new HashSet<>();
+        // keys are compared by identity, so equal but distinct keys must not 
be merged
+        Set<K> ret = Collections.newSetFromMap(new IdentityHashMap<>());

Review Comment:
   Not quite: the backingStore keys are IdentityWeakReferences, whose 
hashCode()/equals() are identity-based (System.identityHashCode and get() == 
ref.get()), so equal-but-distinct keys are stored as separate entries. The 
collapse happened when keySet() unwrapped them into a plain HashSet<K>, which 
is equals-based. With only the CacheMap.remove() change and the old keySet(), 
testRemoveWithMultipleEqualKeys still fails, because the List in remove() is 
built from the already-collapsed set. Returning an identity-based set keeps 
keySet() consistent with the map’s own identity semantics.



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