tisonkun commented on code in PR #1996: URL: https://github.com/apache/zookeeper/pull/1996#discussion_r1326764080
########## zookeeper-server/src/main/java/org/apache/zookeeper/ClientCnxn.java: ########## @@ -855,10 +855,22 @@ class SendThread extends ZooKeeperThread { private boolean isFirstConnect = true; private volatile ZooKeeperSaslClient zooKeeperSaslClient; - private String stripChroot(String serverPath) { + String stripChroot(String serverPath) { if (serverPath.startsWith(chrootPath)) { if (serverPath.length() == chrootPath.length()) { return "/"; + } else if (serverPath.charAt(chrootPath.length()) != '/') { + // Corner-case: + // * Event for config node "/zookeeper/config". + // * Chroot "/zoo". + // + // We can't simply deliver "/zookeeper/config" in all cases, as + // getData("/config") in chroot "/zookeeper" expect "/config". + // But at least, we should not deliver abnormal path here. + // + // It might be better to move chroot out of here as ZOOKEEPER-838 + // suggested, but it is another story. + return serverPath; } return serverPath.substring(chrootPath.length()); } else if (serverPath.startsWith(ZooDefs.ZOOKEEPER_NODE_SUBTREE)) { Review Comment: I wonder if we can simply switch the if conditions order. That is: ```java if (serverPath.startsWith(ZooDefs.ZOOKEEPER_NODE_SUBTREE)) { return serverPath; } else if (serverPath.startsWith(chrootPath)) { // ... } ``` -- 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. To unsubscribe, e-mail: notifications-unsubscr...@zookeeper.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org