gnodet commented on PR #12630: URL: https://github.com/apache/maven/pull/12630#issuecomment-5438278423
FYI — #12865 is an alternative approach to this same issue that addresses the review feedback from @gnodet: 1. **TOCTOU race**: fixed by using `ConcurrentHashMap.putIfAbsent()` in the cache `put()` methods, so the cache insertion is atomic. Callers detect when another thread won the race (via identity check on the returned realm) and dispose the redundant `ClassRealm`. 2. **Also fixes `DefaultExtensionRealmCache` and `DefaultPluginArtifactsCache`** which have the same non-atomic `containsKey()` + `put()` pattern and are exposed to concurrent access once the `synchronized` is removed. 3. **Includes a concurrent test** with 8 threads and `CyclicBarrier` for maximum contention. Happy to defer to the maintainers on which approach to go with. -- 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]
