jiajunwang commented on a change in pull request #1751:
URL: https://github.com/apache/helix/pull/1751#discussion_r639300704



##########
File path: 
helix-core/src/main/java/org/apache/helix/spectator/RoutingTableProvider.java
##########
@@ -751,51 +754,49 @@ private void 
updateCurrentStatesListeners(List<LiveInstance> liveInstances,
 
     if (changeContext.getType() == NotificationContext.Type.FINALIZE) {
       // on finalize, should remove all current-state listeners
-      logger.info("remove current-state listeners. lastSeenSessions: {}", 
_lastSeenSessions);
+      logger.info("remove current-state listeners. lastSeenSessions: {}", 
_lastSeenSessions.get());
       liveInstances = Collections.emptyList();
     }
 
-    Map<String, LiveInstance> curSessions = new HashMap<>();
-    for (LiveInstance liveInstance : liveInstances) {
-      curSessions.put(liveInstance.getEphemeralOwner(), liveInstance);
-    }
+    Map<String, LiveInstance> curSessions = liveInstances.stream().collect(
+        Collectors.toConcurrentMap(LiveInstance::getEphemeralOwner, 
liveInstance -> liveInstance));
 
-    // Go though the live instance list and update CurrentState listeners
-    synchronized (_lastSeenSessions) {

Review comment:
       Here's my proof: Every _lastSeenSessions update is followed by cleanup. 
If clean-up does not fail, then we won't have leakage. Otherwise, there is no 
recovery anyway.
   One potential exception is that the shutdown happens earlier than the final 
onLiveInstance event processing. In this case, the final event processing logic 
actually sees a clean session record (updated by the shutdown process). 
However, this is not possible. Because in this PR, I remove the onLiveInstance 
listener before initializing the shutdown process. It is guaranteed that there 
is no onLiveInstance event being processed after shutdown.




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to