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:18:34 UTC

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

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



##########
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:
       The problem you mentioned cannot be solved simply like this. If other thread remove the thread, it will still throw `ConcurrentModificationException`.

##########
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:
       The problem you mentioned cannot be solved simply like this. If other thread remove the element, it will still throw `ConcurrentModificationException`.

##########
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:
       The problem you mentioned cannot be solved simply like this. If other thread removes the element concurrently, it will still throw `ConcurrentModificationException`.




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