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 2017/07/16 21:06:19 UTC

[02/21] curator git commit: SharedCount: fix removeListener

SharedCount: fix removeListener

`removeListener` only removed the listener from the SharedCount's `listeners` member, which had no effect.
This fix retrieves the `SharedValueListener` created for wrapping the `SharedCountListener` and removes it from the SharedValue's listeners.

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

Branch: refs/heads/CURATOR-419
Commit: b1ffac9145750e03c01c4ce6823f4a8536054a1e
Parents: 8b28b12
Author: Niv Singer <ni...@innerlogics.com>
Authored: Wed Jul 5 11:47:13 2017 +0300
Committer: GitHub <no...@github.com>
Committed: Wed Jul 5 11:47:13 2017 +0300

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/shared/SharedCount.java    | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/b1ffac91/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
index 87fffdd..50a9f0e 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedCount.java
@@ -141,7 +141,10 @@ public class SharedCount implements Closeable, SharedCountReader, Listenable<Sha
     @Override
     public void     removeListener(SharedCountListener listener)
     {
-        listeners.remove(listener);
+        SharedValueListener valueListener = listeners.remove(listener);
+        if(valueListener != null) {
+            sharedValue.getListenable().removeListener(valueListener);
+        }
     }
 
     /**