adoroszlai commented on a change in pull request #2895:
URL: https://github.com/apache/ozone/pull/2895#discussion_r764596287



##########
File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/utils/ResourceLimitCache.java
##########
@@ -79,7 +79,11 @@ public V remove(K key) {
   @Override
   public void removeIf(Predicate<K> predicate) {
     Objects.requireNonNull(predicate);
-    map.keySet().removeIf(predicate);
+    for (K key : new ArrayList<>(map.keySet())) {

Review comment:
       Yes, `ConcurrentHashMap` doc says that its iterator does not throw 
`ConcurrentModificationException`.  However, `ResourceLimitCache` accepts any 
`ConcurrentMap`, and this interface does not state the same (i.e. I am not sure 
it is a requirement for all implementations).  So I preferred to be on the safe 
side.
   
   Since `clear()` already iterates `keySet` directly, I guess we can still get 
rid of the wrapping `ArrayList`, so I have updated the patch.




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

Reply via email to