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:21 UTC

[04/21] curator git commit: Make sure readValueAndNotifyListenersInBackground() is called after a connection problem

Make sure readValueAndNotifyListenersInBackground() is called after a connection problem


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

Branch: refs/heads/CURATOR-419
Commit: 5de6b818a8180291a6769e8db7d14b370dfb5221
Parents: 174faef
Author: randgalt <ra...@apache.org>
Authored: Mon Jul 10 11:05:57 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Mon Jul 10 11:05:57 2017 -0500

----------------------------------------------------------------------
 .../apache/curator/framework/recipes/shared/SharedValue.java | 5 +++--
 .../curator/framework/recipes/shared/TestSharedCount.java    | 8 +++-----
 2 files changed, 6 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/5de6b818/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
index 68fd5b5..5d7abce 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/shared/SharedValue.java
@@ -79,7 +79,7 @@ public class SharedValue implements Closeable, SharedValueReader
         public void stateChanged(CuratorFramework client, ConnectionState newState)
         {
             notifyListenerOfStateChanged(newState);
-            if ( newState == ConnectionState.RECONNECTED )
+            if ( newState.isConnected() )
             {
                 try
                 {
@@ -87,6 +87,7 @@ public class SharedValue implements Closeable, SharedValueReader
                 }
                 catch ( Exception e )
                 {
+                    ThreadUtils.checkInterrupted(e);
                     log.error("Could not read value after reconnect", e);
                 }
             }
@@ -115,7 +116,7 @@ public class SharedValue implements Closeable, SharedValueReader
     }
 
     @VisibleForTesting
-    protected SharedValue(CuratorFramework client, String path, byte[] seedValue, CuratorWatcher watcher)
+    protected SharedValue(WatcherRemoveCuratorFramework client, String path, byte[] seedValue, CuratorWatcher watcher)
     {
         this.client = client;
         this.path = PathUtils.validatePath(path);

http://git-wip-us.apache.org/repos/asf/curator/blob/5de6b818/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
index d7ebb6c..3123c7d 100644
--- a/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
+++ b/curator-recipes/src/test/java/org/apache/curator/framework/recipes/shared/TestSharedCount.java
@@ -516,18 +516,16 @@ public class TestSharedCount extends BaseClassForTests
 
     private SharedCount createSharedCountWithFaultyWatcher(CuratorFramework curatorFramework, String path, int val) {
 
-        class FaultyCuratorWatcher implements CuratorWatcher {
+        final CuratorWatcher faultyWatcher = new CuratorWatcher() {
             @Override
             public void process(WatchedEvent event) throws Exception {
                 // everything will be ignored
             }
-        }
-
-        final FaultyCuratorWatcher fautlyWatcher = new FaultyCuratorWatcher();
+        };
 
         class FaultySharedValue extends SharedValue {
             public FaultySharedValue(CuratorFramework client, String path, byte[] seedValue) {
-                super(client, path, seedValue, fautlyWatcher);
+                super(client.newWatcherRemoveCuratorFramework(), path, seedValue, faultyWatcher);
             }
         };