You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/07/23 18:04:44 UTC

[GitHub] sijie closed pull request #1558: [dlog] Issue 1544: ConcurrentModificationException with nonblocking logReader.readNext(true)

sijie closed pull request #1558: [dlog] Issue 1544: ConcurrentModificationException with nonblocking logReader.readNext(true)
URL: https://github.com/apache/bookkeeper/pull/1558
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java
index d78b4550f7..f688f445db 100644
--- a/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java
+++ b/stream/distributedlog/core/src/main/java/org/apache/distributedlog/impl/ZKLogSegmentMetadataStore.java
@@ -476,8 +476,12 @@ void notifyLogStreamDeleted(String logSegmentsPath,
             return;
         }
         this.submitTask(logSegmentsPath, () -> {
-            for (LogSegmentNamesListener listener : listeners.keySet()) {
-                listener.onLogStreamDeleted();
+            // the listener map might be updated in different threads (e.g. unregisterLogSegmentListener)
+            // so access it under a synchronization block
+            synchronized (listeners) {
+                for (LogSegmentNamesListener listener : listeners.keySet()) {
+                    listener.onLogStreamDeleted();
+                }
             }
         });
 
@@ -490,8 +494,12 @@ void notifyLogSegmentsUpdated(String logSegmentsPath,
             return;
         }
         this.submitTask(logSegmentsPath, () -> {
-            for (VersionedLogSegmentNamesListener listener : listeners.values()) {
-                listener.onSegmentsUpdated(segments);
+            // the listener map might be updated in different threads (e.g. unregisterLogSegmentListener)
+            // so access it under a synchronization block
+            synchronized (listeners) {
+                for (VersionedLogSegmentNamesListener listener : listeners.values()) {
+                    listener.onSegmentsUpdated(segments);
+                }
             }
         });
     }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services