linlinnn commented on a change in pull request #10536:
URL: https://github.com/apache/pulsar/pull/10536#discussion_r630099590



##########
File path: 
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/coordination/impl/LockManagerImpl.java
##########
@@ -115,9 +115,11 @@ private void handleSessionEvent(SessionEvent se) {
 
     private void handleDataNotification(Notification n) {
         if (n.getType() == NotificationType.Deleted) {
-            locks.stream()
-                    .filter(l -> l.getPath().equals(n.getPath()))
-                    .forEach(l -> l.lockWasInvalidated());
+            for (ResourceLockImpl<T> lock : locks) {

Review comment:
       I think we cannot fix it in this way.
   Because if other thread removes the element during create the list, it will 
throw `ConcurrentModificationException` when call `forEachRemaining(action)`.
   The simpliest way is to use `CopyOnWriteArraySet` instead of `HashSet`,
   or add a lock.




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


Reply via email to