belugabehr commented on a change in pull request #2312:
URL: https://github.com/apache/hive/pull/2312#discussion_r639709847



##########
File path: 
ql/src/java/org/apache/hadoop/hive/ql/cache/results/QueryResultsCache.java
##########
@@ -783,13 +755,11 @@ private boolean hasSpaceForCacheEntry(CacheEntry entry, 
long size) {
 
   private CacheEntry findEntryToRemove() {
     // Entries should be in LRU order in the keyset iterator.
-    Set<CacheEntry> entries = lru.keySet();
     synchronized (lru) {
-      for (CacheEntry removalCandidate : entries) {
-        if (removalCandidate.getStatus() != CacheEntryStatus.VALID) {
-          continue;
+      for (CacheEntry removalCandidate : lru) {
+        if (removalCandidate.getStatus() == CacheEntryStatus.VALID) {
+          return removalCandidate;
         }
-        return removalCandidate;

Review comment:
       Grab the `keySet` _inside_ of the synchronized block to avoid 
ConcurrentModification. Remove use of 'continue' keyword.




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

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to