Affected version: HEAD
File: maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/ConcurrentWeakCache.java:124-146
V existing = get(key); // fast path
if (existing != null) {
return existing;
}
The fast-path get() uses a ThreadLocal LookupKey. Between get() returning null and merge() at line 135, another thread can insert a new value. The merge correctly handles this, but if get() returns a non-null reference to a key that gets GC'd immediately after, we return a stale reference. This is a correct-by-accident pattern — the merge would fix it, but we return early.
Originally reported in #1944.
Affected version: HEAD
File:
maven-resolver-util/src/main/java/org/eclipse/aether/util/concurrency/ConcurrentWeakCache.java:124-146The fast-path
get()uses a ThreadLocalLookupKey. Betweenget()returning null andmerge()at line 135, another thread can insert a new value. The merge correctly handles this, but ifget()returns a non-null reference to a key that gets GC'd immediately after, we return a stale reference. This is a correct-by-accident pattern — the merge would fix it, but we return early.Originally reported in #1944.