curator-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dragonsi...@apache.org
Subject [2/6] git commit: Add precondition checks.
Date Mon, 06 Oct 2014 23:52:25 GMT
Add precondition checks.


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

Branch: refs/heads/master
Commit: 825a96252d6f6101c1163d340375ad1339f996d3
Parents: a8ff472
Author: Scott Blum <scottb@squareup.com>
Authored: Fri Aug 22 17:14:44 2014 -0400
Committer: Scott Blum <scottb@squareup.com>
Committed: Fri Aug 22 17:14:44 2014 -0400

----------------------------------------------------------------------
 .../apache/curator/utils/CloseableExecutorService.java  |  2 +-
 .../curator/framework/recipes/cache/TreeCache.java      | 12 +++++++-----
 2 files changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/825a9625/curator-client/src/main/java/org/apache/curator/utils/CloseableExecutorService.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/utils/CloseableExecutorService.java
b/curator-client/src/main/java/org/apache/curator/utils/CloseableExecutorService.java
index e9d2547..721754d 100644
--- a/curator-client/src/main/java/org/apache/curator/utils/CloseableExecutorService.java
+++ b/curator-client/src/main/java/org/apache/curator/utils/CloseableExecutorService.java
@@ -116,7 +116,7 @@ public class CloseableExecutorService implements Closeable
      */
     public CloseableExecutorService(ExecutorService executorService, boolean shutdownOnClose)
     {
-        this.executorService = executorService;
+        this.executorService = Preconditions.checkNotNull(executorService);
         this.shutdownOnClose = shutdownOnClose;
     }
 

http://git-wip-us.apache.org/repos/asf/curator/blob/825a9625/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
----------------------------------------------------------------------
diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
index 3de3a04..030ea2c 100644
--- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
+++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/TreeCache.java
@@ -30,7 +30,6 @@ import org.apache.curator.framework.listen.ListenerContainer;
 import org.apache.curator.framework.state.ConnectionState;
 import org.apache.curator.framework.state.ConnectionStateListener;
 import org.apache.curator.utils.CloseableExecutorService;
-import org.apache.curator.utils.PathUtils;
 import org.apache.curator.utils.ThreadUtils;
 import org.apache.curator.utils.ZKPaths;
 import org.apache.zookeeper.KeeperException;
@@ -52,6 +51,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.atomic.AtomicReference;
 
+import static com.google.common.base.Preconditions.checkNotNull;
+import static org.apache.curator.utils.PathUtils.validatePath;
+
 /**
  * <p>A utility that attempts to keep all data from all children of a ZK path locally
cached. This class
  * will watch the ZK path, respond to update/create/delete events, pull down the data, etc.
You can
@@ -73,8 +75,8 @@ public class TreeCache implements Closeable
         private CloseableExecutorService executorService = null;
 
         private Builder(CuratorFramework client, String path) {
-            this.client = client;
-            this.path = path;
+            this.client = checkNotNull(client);
+            this.path = validatePath(path);
         }
 
         /**
@@ -143,7 +145,7 @@ public class TreeCache implements Closeable
          */
         public Builder setExecutor(CloseableExecutorService executorService)
         {
-            this.executorService = executorService;
+            this.executorService = checkNotNull(executorService);
             return this;
         }
     }
@@ -485,7 +487,7 @@ public class TreeCache implements Closeable
      */
     TreeCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed,
final CloseableExecutorService executorService)
     {
-        this.root = new TreeNode(PathUtils.validatePath(path), null);
+        this.root = new TreeNode(validatePath(path), null);
         this.client = client;
         this.cacheData = cacheData;
         this.dataIsCompressed = dataIsCompressed;


Mime
View raw message