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/05/28 14:10:43 UTC

[1/2] curator git commit: changed exceptions to logging. This is test code

Repository: curator
Updated Branches:
  refs/heads/CURATOR-411 a0ab8772c -> d4f15297d


changed exceptions to logging. This is test code


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

Branch: refs/heads/CURATOR-411
Commit: 9403703ad94d6d2e54d4cf393a24affab130f2d1
Parents: a0ab877
Author: randgalt <ra...@apache.org>
Authored: Sun May 28 09:10:16 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun May 28 09:10:16 2017 -0500

----------------------------------------------------------------------
 .../main/java/org/apache/curator/test/DirectoryUtils.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/9403703a/curator-test/src/main/java/org/apache/curator/test/DirectoryUtils.java
----------------------------------------------------------------------
diff --git a/curator-test/src/main/java/org/apache/curator/test/DirectoryUtils.java b/curator-test/src/main/java/org/apache/curator/test/DirectoryUtils.java
index 9f00dd1..134aa5f 100644
--- a/curator-test/src/main/java/org/apache/curator/test/DirectoryUtils.java
+++ b/curator-test/src/main/java/org/apache/curator/test/DirectoryUtils.java
@@ -19,20 +19,25 @@
 package org.apache.curator.test;
 
 import com.google.common.base.Preconditions;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import java.io.File;
 import java.io.IOException;
 
 // copied from Google Guava as these methods are now deprecated
 // NOTE: removed the line of code documented: Symbolic links will have different canonical and absolute paths
+// Update May 28, 2017 - change exception into logs
 public class DirectoryUtils
 {
+    private static final Logger log = LoggerFactory.getLogger(DirectoryUtils.class);
+
     public static void deleteRecursively(File file) throws IOException
     {
         if (file.isDirectory()) {
             deleteDirectoryContents(file);
         }
         if (!file.delete()) {
-            throw new IOException("Failed to delete " + file);
+            log.error("Failed to delete " + file);
         }
     }
 
@@ -42,7 +47,8 @@ public class DirectoryUtils
             "Not a directory: %s", directory);
         File[] files = directory.listFiles();
         if (files == null) {
-            throw new IOException("Error listing files for " + directory);
+            log.warn("directory.listFiles() returned null for: " + directory);
+            return;
         }
         for (File file : files) {
             deleteRecursively(file);


[2/2] curator git commit: In testNewMembers the smallCluster wasn't getting closed at the end of the test.

Posted by ra...@apache.org.
In testNewMembers the smallCluster wasn't getting closed at the end of the test.


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

Branch: refs/heads/CURATOR-411
Commit: d4f15297d3594b80b94cf686210999f9c141d5b4
Parents: 9403703
Author: randgalt <ra...@apache.org>
Authored: Sun May 28 09:10:38 2017 -0500
Committer: randgalt <ra...@apache.org>
Committed: Sun May 28 09:10:38 2017 -0500

----------------------------------------------------------------------
 .../framework/imps/TestReconfiguration.java     | 56 ++++++++++++--------
 1 file changed, 34 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/d4f15297/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
----------------------------------------------------------------------
diff --git a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
index 83ebf74..fc89134 100644
--- a/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
+++ b/curator-framework/src/test/java/org/apache/curator/framework/imps/TestReconfiguration.java
@@ -290,34 +290,46 @@ public class TestReconfiguration extends BaseClassForTests
     public void testNewMembers() throws Exception
     {
         cluster.close();
-        cluster = new TestingCluster(5);
-        List<TestingZooKeeperServer> servers = cluster.getServers();
-        List<InstanceSpec> smallCluster = Lists.newArrayList();
-        for ( int i = 0; i < 3; ++i )   // only start 3 of the 5
-        {
-            TestingZooKeeperServer server = servers.get(i);
-            server.start();
-            smallCluster.add(server.getInstanceSpec());
-        }
+        cluster = null;
 
-        try ( CuratorFramework client = newClient(new TestingCluster(smallCluster).getConnectString()))
+        TestingCluster smallCluster = null;
+        TestingCluster localCluster = new TestingCluster(5);
+        try
         {
-            client.start();
+            List<TestingZooKeeperServer> servers = localCluster.getServers();
+            List<InstanceSpec> smallClusterInstances = Lists.newArrayList();
+            for ( int i = 0; i < 3; ++i )   // only start 3 of the 5
+            {
+                TestingZooKeeperServer server = servers.get(i);
+                server.start();
+                smallClusterInstances.add(server.getInstanceSpec());
+            }
 
-            QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
-            Assert.assertEquals(oldConfig.getAllMembers().size(), 5);
-            assertConfig(oldConfig, cluster.getInstances());
+            smallCluster = new TestingCluster(smallClusterInstances);
+            try ( CuratorFramework client = newClient(smallCluster.getConnectString()))
+            {
+                client.start();
 
-            CountDownLatch latch = setChangeWaiter(client);
+                QuorumVerifier oldConfig = toQuorumVerifier(client.getConfig().forEnsemble());
+                Assert.assertEquals(oldConfig.getAllMembers().size(), 5);
+                assertConfig(oldConfig, localCluster.getInstances());
 
-            client.reconfig().withNewMembers(toReconfigSpec(smallCluster)).forEnsemble();
+                CountDownLatch latch = setChangeWaiter(client);
 
-            Assert.assertTrue(timing.awaitLatch(latch));
-            byte[] newConfigData = client.getConfig().forEnsemble();
-            QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
-            Assert.assertEquals(newConfig.getAllMembers().size(), 3);
-            assertConfig(newConfig, smallCluster);
-            Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+                client.reconfig().withNewMembers(toReconfigSpec(smallClusterInstances)).forEnsemble();
+
+                Assert.assertTrue(timing.awaitLatch(latch));
+                byte[] newConfigData = client.getConfig().forEnsemble();
+                QuorumVerifier newConfig = toQuorumVerifier(newConfigData);
+                Assert.assertEquals(newConfig.getAllMembers().size(), 3);
+                assertConfig(newConfig, smallClusterInstances);
+                Assert.assertEquals(EnsembleTracker.configToConnectionString(newConfig), ensembleProvider.getConnectionString());
+            }
+        }
+        finally
+        {
+            CloseableUtils.closeQuietly(smallCluster);
+            CloseableUtils.closeQuietly(localCluster);
         }
     }