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

    https://github.com/apache/zookeeper/pull/136#discussion_r132034154
  
    --- Diff: src/java/main/org/apache/zookeeper/server/WatchManager.java ---
    @@ -97,23 +102,44 @@ synchronized void removeWatcher(Watcher watcher) {
         Set<Watcher> triggerWatch(String path, EventType type, Set<Watcher> 
supress) {
             WatchedEvent e = new WatchedEvent(type,
                     KeeperState.SyncConnected, path);
    -        HashSet<Watcher> watchers;
    +        Set<Watcher> watchers = new HashSet<>();
    +        PathIterator pathIterator = new PathIterator(path);
             synchronized (this) {
    -            watchers = watchTable.remove(path);
    -            if (watchers == null || watchers.isEmpty()) {
    -                if (LOG.isTraceEnabled()) {
    -                    ZooTrace.logTraceMessage(LOG,
    -                            ZooTrace.EVENT_DELIVERY_TRACE_MASK,
    -                            "No watchers for " + path);
    +            for (String localPath : pathIterator.asIterable()) {
    +                Map<Watcher, Type> thisWatchers = 
watchTable.get(localPath);
    +                if (thisWatchers == null || thisWatchers.isEmpty()) {
    +                    continue;
                     }
    -                return null;
    -            }
    -            for (Watcher w : watchers) {
    -                HashSet<String> paths = watch2Paths.get(w);
    -                if (paths != null) {
    -                    paths.remove(path);
    +                Iterator<Entry<Watcher, Type>> iterator = 
thisWatchers.entrySet().iterator();
    +                while (iterator.hasNext()) {
    +                    Entry<Watcher, Type> entry = iterator.next();
    +                    Type entryType = entry.getValue();
    +                    Watcher watcher = entry.getKey();
    +                    if (entryType == Type.PERSISTENT) {
    +                        if ( type != EventType.NodeChildrenChanged ) {
    +                            watchers.add(watcher);
    --- End diff --
    
    Well, other watchers are in a set so I don't think it matters. Sets solve 
other guarantees of watchers.


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