address review comments

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

Branch: refs/heads/master
Commit: 53c47706913cc4e22c4fc229bc8bc95a730077fd
Parents: 60e9be8
Author: Rama <rama....@salesforce.com>
Authored: Mon Sep 24 13:17:15 2018 +0530
Committer: Rama <rama....@salesforce.com>
Committed: Mon Sep 24 13:17:15 2018 +0530

----------------------------------------------------------------------
 .../framework/recipes/cache/TreeCache.java      | 23 +++++---------------
 1 file changed, 6 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/curator/blob/53c47706/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 70e0abd..b6911f3 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
@@ -44,11 +44,11 @@ import 
java.util.concurrent.atomic.AtomicReferenceFieldUpdater;
 import org.apache.curator.framework.CuratorFramework;
 import org.apache.curator.framework.WatcherRemoveCuratorFramework;
 import org.apache.curator.framework.api.BackgroundCallback;
+import org.apache.curator.framework.api.BackgroundPathable;
 import org.apache.curator.framework.api.CuratorEvent;
-import org.apache.curator.framework.api.ErrorListenerPathable;
-import org.apache.curator.framework.api.GetDataBuilder;
-import org.apache.curator.framework.api.GetDataWatchBackgroundStatable;
+import org.apache.curator.framework.api.Pathable;
 import org.apache.curator.framework.api.UnhandledErrorListener;
+import org.apache.curator.framework.api.Watchable;
 import org.apache.curator.framework.listen.Listenable;
 import org.apache.curator.framework.listen.ListenerContainer;
 import org.apache.curator.framework.state.ConnectionState;
@@ -270,11 +270,7 @@ public class TreeCache implements Closeable
         {
             if ( treeState.get() == TreeState.STARTED )
             {
-                if (disableZkWatches) {
-                    client.getChildren().inBackground(this).forPath(path);
-                } else {
-                    
client.getChildren().usingWatcher(this).inBackground(this).forPath(path);
-                }
+                maybeWatch(client.getChildren()).forPath(path);
             }
         }
 
@@ -293,15 +289,8 @@ public class TreeCache implements Closeable
             }
         }
 
-        private ErrorListenerPathable<byte[]> 
maybeWatch(GetDataWatchBackgroundStatable dataBuilder) {
-            if (disableZkWatches) {
-                return dataBuilder.inBackground(this);
-            } else {
-                return dataBuilder.usingWatcher(this).inBackground(this);
-            }
-        }
-
-        private ErrorListenerPathable<byte[]> maybeWatch(GetDataBuilder 
dataBuilder) {
+        private <T, P extends Watchable<BackgroundPathable<T>> & 
BackgroundPathable<T>> Pathable<T> maybeWatch(
+            P dataBuilder) {
             if (disableZkWatches) {
                 return dataBuilder.inBackground(this);
             } else {

Reply via email to