kaisun2000 commented on a change in pull request #924: WIP: fix 
ZkHelixPropertyStore loses Zookeeper notification issue
URL: https://github.com/apache/helix/pull/924#discussion_r401182893
 
 

 ##########
 File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
 ##########
 @@ -1073,10 +1073,24 @@ protected void processStateChanged(WatchedEvent event) 
{
 
     fireStateChangedEvent(event.getState());
 
+    // This following is the case for sharedZkClient
     if (!isManagingZkConnection()) {
+      /*
+       For SharedZkClient, we will not invoke fireNewSessionEvents and we will 
invoke fireAllEvents
+       This keeps the same behavior as original SharedZkClient.
+       Invoking fireAllEvents is important to make sure HelixPropertyStore 
working correctly.
+      */
+      if ((event.getState() == KeeperState.SyncConnected) && 
(!_isNewSessionEventFired) && (!"0"
+          .equals(getHexSessionId()))) {
+        fireAllEvents();
+        _isNewSessionEventFired = true;
+      } else if (event.getState() == KeeperState.Expired) {
+        _isNewSessionEventFired = false;
+      }
       return;
 
 Review comment:
   Strictly speaking, this is not from sub-class. This is one object of a class 
that can act on different roles. But I get what you are thinking.
   
   That said, traditionally it is like this. 
   
   I can write in an another concise way wrapping all this logic into the if 
block of 1093. 
   
   Thought about it. The drawback of that way would be losing readability, and 
thus the intention of the logic. This would pave the way of next hidden bug 
when people do refactoring later, just as how this bug is introduced.

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


With regards,
Apache Git Services

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

Reply via email to