iprithv commented on code in PR #16212:
URL: https://github.com/apache/lucene/pull/16212#discussion_r3378497224
##########
lucene/core/src/java/org/apache/lucene/search/LRUQueryCache.java:
##########
@@ -1290,14 +1319,8 @@ public synchronized void cleanUp() {
keysToClean.removeAll(keysToCleanCopy);
queriesToClean.removeAll(queriesToCleanCopy);
- for (QueryCacheKey queryCacheKey : keys()) {
Review Comment:
taking a snapshot of cache.keySet() still requires holding a lock, HashMap
isn't thread-safe, so even copying it while another thread calls putIfAbsent
can throw ConcurrentModificationException or silently corrupt. so a snapshot
doesn't avoid the lock, it just adds an extra copy.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]