You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@curator.apache.org by ra...@apache.org on 2014/05/23 14:49:13 UTC

[2/3] git commit: use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak

use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak


Project: http://git-wip-us.apache.org/repos/asf/curator/repo
Commit: http://git-wip-us.apache.org/repos/asf/curator/commit/91d65037
Tree: http://git-wip-us.apache.org/repos/asf/curator/tree/91d65037
Diff: http://git-wip-us.apache.org/repos/asf/curator/diff/91d65037

Branch: refs/heads/CURATOR-107
Commit: 91d65037bf28947b5b28b75ec83614bb70a3e12a
Parents: 290186a
Author: randgalt <ra...@apache.org>
Authored: Fri May 23 07:47:56 2014 -0500
Committer: randgalt <ra...@apache.org>
Committed: Fri May 23 07:47:56 2014 -0500

----------------------------------------------------------------------
 .../org/apache/curator/framework/recipes/leader/LeaderLatch.java  | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/91d65037/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
index ecdd903..88456af 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/leader/LeaderLatch.java
@@ -519,7 +519,8 @@ public class LeaderLatch implements Closeable
                     }
                 }
             };
-            client.checkExists().usingWatcher(watcher).inBackground(callback).forPath(ZKPaths.makePath(latchPath, watchPath));
+            // use getData() instead of exists() to avoid leaving unneeded watchers which is a type of resource leak
+            client.getData().usingWatcher(watcher).inBackground(callback).forPath(ZKPaths.makePath(latchPath, watchPath));
         }
     }