[
https://issues.apache.org/jira/browse/ZOOKEEPER-4565?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17567771#comment-17567771
]
Kezhu Wang commented on ZOOKEEPER-4565:
---------------------------------------
I presented a possible solution in
[pr#1899|https://github.com/apache/zookeeper/pull/1899]. But I think there are
subtle situations that we should aware of. What happen if the chroot is
"/zookeeper" ?
The currently behaviors(pr#1899 keeps this) is that:
* Both {{getData}} and {{getConfig}} will issue event with path "/config" for
"/zookeeper/config".
It sounds a bit surprising that {{getConfig}} behaves different due to chroot.
Personally, I prefer to:
* {{getConfig}} always get events with path "/zookeeper/config".
* {{getData}} and others get events with path stripped by chroot.
I think we chould intercept {{watcher}} in {{getConfig}} to achieve this.
But this might be a breaking change to old behavior though probably not by
design.
What do you think ? [~eolivelli] [~symat] [~maoling] [~Tison]
> Config watch path get truncated abnormally and fail chroot zookeeper client
> ---------------------------------------------------------------------------
>
> Key: ZOOKEEPER-4565
> URL: https://issues.apache.org/jira/browse/ZOOKEEPER-4565
> Project: ZooKeeper
> Issue Type: Bug
> Components: java client
> Affects Versions: 3.6.3, 3.8.0, 3.7.1, 3.9.0
> Reporter: Kezhu Wang
> Assignee: Kezhu Wang
> Priority: Major
> Labels: pull-request-available
> Time Spent: 20m
> Remaining Estimate: 0h
>
> {{ClientCnxn}} strips off {{chrootPath}} for notifications. This strip could
> break "/zookeeper/config" to illegal zookeeper path(aka. not start with "/")
> and fail zookeeper client due to index out of bound exception in
> {{PathParentIterator.next}}.
> {code:java}
> // convert from a server path to a client path
> if (chrootPath != null) {
> String serverPath = event.getPath();
> if (serverPath.compareTo(chrootPath) == 0) {
> event.setPath("/");
> } else if (serverPath.length() > chrootPath.length()) {
>
> event.setPath(serverPath.substring(chrootPath.length()));
> } else {
> LOG.warn("Got server path {} which is too short for
> chroot path {}.",
> event.getPath(), chrootPath);
> }
> }
> {code}
> I think we could make this strip similar to c client version {{sub_string}}
> and warns only for not "/zookeeper" nodes.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)