dasahcc commented on a change in pull request #1526:
URL: https://github.com/apache/helix/pull/1526#discussion_r521603216



##########
File path: 
zookeeper-api/src/main/java/org/apache/helix/zookeeper/zkclient/ZkConnection.java
##########
@@ -132,10 +136,59 @@ public boolean exists(String path, boolean watch) throws 
KeeperException, Interr
     return _zk.exists(path, watch) != null;
   }
 
+  /**
+   * Returns a list of children of the given path.
+   * <p>
+   * If the watch is non-null and the call is successful (no exception is 
thrown),
+   * a watch will be left on the node with the given path.
+   * <p>
+   * The implementation uses java reflection to check whether the native zk 
supports
+   * paginated getChildren API: if yes, use the paginated API; otherwise, fall 
back to
+   * the non-paginated API.
+   *
+   * @param path the path of the node
+   * @param watch a boolean flag to indicate whether the watch should be added 
to the node
+   * @return a list of children of the given path
+   * @throws KeeperException if the server signals an error with a non-zero 
error code
+   * @throws InterruptedException if the server transaction is interrupted
+   */
   @Override
   public List<String> getChildren(final String path, final boolean watch)
       throws KeeperException, InterruptedException {
-    return _zk.getChildren(path, watch);
+    checkPaginatedGetChildren();
+    try {
+      // This cast is correct because the list we're creating
+      // is of the same type as the one passed in, which is List<String>.
+      @SuppressWarnings("unchecked")
+      List<String> children = (List<String>) (_isPaginationSupported
+          ? _getChildrenMethod.invoke(_zk, path, watch, -1, -1, -1)
+          : _getChildrenMethod.invoke(_zk, path, watch));

Review comment:
       This implementation could be very confusing... Can we just make a ifelse 
statement and call the function explicitly?




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