Github user afine commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/136#discussion_r132024228
  
    --- Diff: src/java/main/org/apache/zookeeper/server/WatchManager.java ---
    @@ -181,11 +206,18 @@ synchronized void dumpWatches(PrintWriter pwriter, 
boolean byPath) {
          * @return true if the watcher exists, false otherwise
          */
         synchronized boolean containsWatcher(String path, Watcher watcher) {
    -        HashSet<String> paths = watch2Paths.get(watcher);
    -        if (paths == null || !paths.contains(path)) {
    -            return false;
    +        PathIterator pathIterator = new PathIterator(path);
    +        for (String localPath : pathIterator.asIterable()) {
    +            Map<Watcher, Type> watchers = watchTable.get(localPath);
    +            Type watcherType = (watchers != null) ? watchers.get(watcher) 
: null;
    +            if ((watcherType == Type.STANDARD) && 
!pathIterator.atParentPath()) {
    --- End diff --
    
    NIT: I feel this is likely to be more performant if we short circuit on 
atParentPath. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to