kaisun2000 commented on a change in pull request #1035:
URL: https://github.com/apache/helix/pull/1035#discussion_r435051521



##########
File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkClient.java
##########
@@ -1865,17 +1934,24 @@ public Object call() throws Exception {
    *         exist.
    */
   public List<String> watchForChilds(final String path) {
+    return watchForChilds(path, false);
+  }
+
+  private List<String> watchForChilds(final String path, boolean 
skipWatchingNodeNotExist) {
     if (_zookeeperEventThread != null && Thread.currentThread() == 
_zookeeperEventThread) {
       throw new IllegalArgumentException("Must not be done in the zookeeper 
event thread.");
     }
     return retryUntilConnected(new Callable<List<String>>() {
       @Override
       public List<String> call() throws Exception {
-        exists(path, true);
+        if (!skipWatchingNodeNotExist) {

Review comment:
       @jiajunwang, the code is like this:
   ```
        public List<String> call() throws Exception {
           if (!skipWatchingNodeNotExist) {
             exists(path, true);
           }
           try {
             return getChildren(path, true);
           } catch (ZkNoNodeException e) {
             // ignore, the "exists" watch will listen for the parent node to 
appear
             LOG.info("watchForChilds path not existing:" + path + " 
skipWatchingNodeNoteExist:" + skipWatchingNodeNotExist);
           }
           return null;
         }
   ```
   
    if skipWatchingNodeNotExist is true, they call getChildren(). 
   
   - If the parent path exists, it would install child change. 
   
   - Otherwise, if parent path not exists, it would not  install parent path. 
Instead, it would return null as child list. This would eventually cause the 
CallbackHandler's handleChildren() code path 
`_manager.removeListener(_propertyKey, _listener);`. This path would remove 
CallbackHandler.




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