junkaixue commented on a change in pull request #1751:
URL: https://github.com/apache/helix/pull/1751#discussion_r639206313
##########
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:
Question, if we remove lock, could be there any in memory leakage of
watchers?
--
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]