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 2016/05/21 16:12:42 UTC

curator git commit: exists() with createParentContainersIfNeeded was ignoring too many KeeperExceptions and thus hiding connection problems. Should only ignore node exists/not-exists

Repository: curator
Updated Branches:
  refs/heads/CURATOR-326 [created] 47003e3e6


exists() with createParentContainersIfNeeded was ignoring too many KeeperExceptions and thus hiding connection problems. Should only ignore node exists/not-exists


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

Branch: refs/heads/CURATOR-326
Commit: 47003e3e6b92ae7a3e41497ae10e99b860e10f87
Parents: 115346b
Author: randgalt <ra...@apache.org>
Authored: Sat May 21 11:12:28 2016 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sat May 21 11:12:28 2016 -0500

----------------------------------------------------------------------
 .../framework/imps/ExistsBuilderImpl.java       |  6 ++-
 .../framework/imps/TestFrameworkEdges.java      | 39 ++++++++++++++++++++
 2 files changed, 44 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/47003e3e/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java b/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
index 5fb7056..da9b0ce 100644
--- a/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
+++ b/curator-framework/src/main/java/org/apache/curator/framework/imps/ExistsBuilderImpl.java
@@ -198,7 +198,11 @@ class ExistsBuilderImpl implements ExistsBuilder, BackgroundOperation<String>, E
                             {
                                 ZKPaths.mkdirs(client.getZooKeeper(), parent, true, client.getAclProvider(), true);
                             }
-                            catch ( KeeperException e )
+                            catch ( KeeperException.NodeExistsException e )
+                            {
+                                // ignore
+                            }
+                            catch ( KeeperException.NoNodeException e )
                             {
                                 // ignore
                             }

http://git-wip-us.apache.org/repos/asf/curator/blob/47003e3e/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
index cefc1e7..553fcb7 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestFrameworkEdges.java
@@ -16,6 +16,7 @@
  * specific language governing permissions and limitations
  * under the License.
  */
+
 package org.apache.curator.framework.imps;
 
 import com.google.common.collect.Queues;
@@ -29,10 +30,12 @@ import org.apache.curator.framework.api.CuratorEventType;
 import org.apache.curator.framework.api.CuratorListener;
 import org.apache.curator.framework.state.ConnectionState;
 import org.apache.curator.framework.state.ConnectionStateListener;
+import org.apache.curator.retry.RetryForever;
 import org.apache.curator.retry.RetryNTimes;
 import org.apache.curator.retry.RetryOneTime;
 import org.apache.curator.test.BaseClassForTests;
 import org.apache.curator.test.KillSession;
+import org.apache.curator.test.TestingServer;
 import org.apache.curator.test.Timing;
 import org.apache.curator.utils.CloseableUtils;
 import org.apache.curator.utils.ZKPaths;
@@ -57,6 +60,42 @@ public class TestFrameworkEdges extends BaseClassForTests
     private final Timing timing = new Timing();
 
     @Test
+    public void testCreateContainersForBadConnect() throws Exception
+    {
+        final int serverPort = server.getPort();
+        server.close();
+
+        CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), 1000, 1000, new RetryForever(100));
+        try
+        {
+            new Thread()
+            {
+                @Override
+                public void run()
+                {
+                    try
+                    {
+                        Thread.sleep(3000);
+                        server = new TestingServer(serverPort, true);
+                    }
+                    catch ( Exception e )
+                    {
+                        e.printStackTrace();
+                    }
+                }
+            }.start();
+
+            client.start();
+            client.createContainers("/this/does/not/exist");
+            Assert.assertNotNull(client.checkExists().forPath("/this/does/not/exist"));
+        }
+        finally
+        {
+            CloseableUtils.closeQuietly(client);
+        }
+    }
+
+    @Test
     public void testProtectedCreateNodeDeletion() throws Exception
     {
         CuratorFramework client = CuratorFrameworkFactory.newClient(server.getConnectString(), timing.session(), 1, new RetryNTimes(0, 0));