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 2014/07/31 17:03:25 UTC

[4/5] git commit: Use Splitter; remove println's.

Use Splitter; remove println's.


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

Branch: refs/heads/CURATOR-33
Commit: eb1bae5b3ed189dd38283ccdb2e0df6fd79dd2bd
Parents: 678e200
Author: Scott Blum <sc...@squareup.com>
Authored: Mon Jul 28 14:05:51 2014 -0400
Committer: Scott Blum <sc...@squareup.com>
Committed: Mon Jul 28 14:05:51 2014 -0400

----------------------------------------------------------------------
 .../java/org/apache/curator/utils/ZKPaths.java  | 21 ++++----------------
 .../framework/recipes/cache/TreeCache.java      |  3 ---
 2 files changed, 4 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/eb1bae5b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
----------------------------------------------------------------------
diff --git a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
index 1ffd71b..1e17217 100644
--- a/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
+++ b/curator-client/src/main/java/org/apache/curator/utils/ZKPaths.java
@@ -18,13 +18,13 @@
  */
 package org.apache.curator.utils;
 
+import com.google.common.base.Splitter;
 import com.google.common.collect.Lists;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZooDefs;
 import org.apache.zookeeper.ZooKeeper;
 import org.apache.zookeeper.data.ACL;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
@@ -112,6 +112,8 @@ public class ZKPaths
         return new PathAndNode(parentPath, node);
     }
 
+    private static final Splitter PATH_SPLITTER = Splitter.on('/').omitEmptyStrings();
+
     /**
      * Given a full path, return the the individual parts, without slashes.
      * The root path will return an empty list.
@@ -122,22 +124,7 @@ public class ZKPaths
     public static List<String> split(String path)
     {
         PathUtils.validatePath(path);
-        if (path.length() == 1) {
-            return Collections.emptyList();
-        }
-        int lastPos = 1;
-        List<String> parts = new ArrayList<String>();
-        while (true)
-        {
-            int nextPos = path.indexOf('/', lastPos);
-            if (nextPos < 0) {
-                parts.add(path.substring(lastPos));
-                break;
-            }
-            parts.add(path.substring(lastPos, nextPos));
-            lastPos = nextPos + 1;
-        }
-        return parts;
+        return PATH_SPLITTER.splitToList(path);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/curator/blob/eb1bae5b/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 f71c21d..4781253 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
@@ -167,7 +167,6 @@ public class TreeCache implements Closeable
         @Override
         public void process(WatchedEvent event)
         {
-            System.out.println(event);
             try
             {
                 switch ( event.getType() )
@@ -196,7 +195,6 @@ public class TreeCache implements Closeable
         @Override
         public void processResult(CuratorFramework client, CuratorEvent event) throws Exception
         {
-            System.out.println(event);
             switch ( event.getType() )
             {
             case EXISTS:
@@ -583,7 +581,6 @@ public class TreeCache implements Closeable
 
     private void publishEvent(final TreeCacheEvent event)
     {
-        System.out.println(event);
         if ( treeState.get() != TreeState.CLOSED )
         {
             executorService.submit(new Runnable()