curator-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdumon <...@git.apache.org>
Subject [GitHub] curator pull request: CURATOR-157 Avoid stack traces on close
Date Thu, 30 Oct 2014 15:15:13 GMT
Github user bdumon commented on a diff in the pull request:

    https://github.com/apache/curator/pull/51#discussion_r19611104
  
    --- Diff: curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java
---
    @@ -382,6 +383,11 @@ public void close() throws IOException
                 connectionStateListener = null;
                 childrenWatcher = null;
                 dataWatcher = null;
    +
    +            synchronized (backgroundTaskMonitor) {
    --- End diff --
    
    An empty synchronized block is not like an empty if statement or such, since "getting
the lock" is a meaningful operation by itself. This being said, I could rewrite it to use
an java.util.concurrent Lock object, or maybe something else?
    
    At a high level, my change will make the close() method wait until a potentially running
background refresh operation has finished (and it also assures that no new refresh can start
after the close method has returned). I guess this should be fine, though it could cause some
delay on the close() in case of very large caches. This could be avoided by extra is-closed
checks in the for-loop in processChildren(). I didn't consider this earlier, I can add it
to my patch.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message