dlg99 commented on code in PR #3365:
URL: https://github.com/apache/bookkeeper/pull/3365#discussion_r908805581


##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java:
##########
@@ -402,6 +402,7 @@ public void registerLedgerMetadataListener(long ledgerId, 
LedgerMetadataListener
                 }
             }
             synchronized (listenerSet) {
+                listenerSet = listeners.computeIfAbsent(ledgerId, k -> new 
HashSet<>());

Review Comment:
   with this, do we still need the lines above:
   ```
   Set<LedgerMetadataListener> listenerSet = listeners.get(ledgerId);
               if (listenerSet == null) {
                   Set<LedgerMetadataListener> newListenerSet = new 
HashSet<LedgerMetadataListener>();
                   Set<LedgerMetadataListener> oldListenerSet = 
listeners.putIfAbsent(ledgerId, newListenerSet);
                   if (null != oldListenerSet) {
                       listenerSet = oldListenerSet;
                   } else {
                       listenerSet = newListenerSet;
                   }
               }
   ```



##########
bookkeeper-server/src/main/java/org/apache/bookkeeper/meta/AbstractZkLedgerManager.java:
##########
@@ -402,6 +402,7 @@ public void registerLedgerMetadataListener(long ledgerId, 
LedgerMetadataListener
                 }
             }
             synchronized (listenerSet) {
+                listenerSet = listeners.computeIfAbsent(ledgerId, k -> new 
HashSet<>());

Review Comment:
   I think this should be before the synchronized block, not inside of it



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

Reply via email to