You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/05/11 06:57:20 UTC

[GitHub] [pulsar] eolivelli commented on a change in pull request #10536: fix lock manager npe when broker shutting down

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



##########
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:
       @linlinnn is right, this code is only rewriting the loop without the stream.
   
   probably the best way is to scan the collection and create a list of locks to be processed, then you scan the list
   
   ```
   List<ResourceLockImpl<T>> invalidated = locks.stream()
                       .filter(l -> l.getPath().equals(n.getPath())).collect(Collectors.toList());
   
   invalidated.forEach(l -> l.lockWasInvalidated())
                       
   ```




-- 
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:
users@infra.apache.org