TreeCache does not need to use CloseableExecutorService.
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 95b8b99..906d23d 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
@@ -32,7 +32,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;
@@ -80,7 +79,7 @@
private final String path;
private boolean cacheData = true;
private boolean dataIsCompressed = false;
- private CloseableExecutorService executorService = null;
+ private ExecutorService executorService = null;
private int maxDepth = Integer.MAX_VALUE;
private boolean createParentNodes = false;
private TreeCacheSelector selector = new DefaultTreeCacheSelector();
@@ -96,10 +95,10 @@
*/
public TreeCache build()
{
- CloseableExecutorService executor = executorService;
+ ExecutorService executor = executorService;
if ( executor == null )
{
- executor = new CloseableExecutorService(Executors.newSingleThreadExecutor(defaultThreadFactory));
+ executor = Executors.newSingleThreadExecutor(defaultThreadFactory);
}
return new TreeCache(client, path, cacheData, dataIsCompressed, maxDepth, executor, createParentNodes, selector);
}
@@ -127,7 +126,7 @@
*/
public Builder setExecutor(ThreadFactory threadFactory)
{
- return setExecutor(new CloseableExecutorService(Executors.newSingleThreadExecutor(threadFactory)));
+ return setExecutor(Executors.newSingleThreadExecutor(threadFactory));
}
/**
@@ -135,21 +134,6 @@
*/
public Builder setExecutor(ExecutorService executorService)
{
- if ( executorService instanceof CloseableExecutorService )
- {
- return setExecutor((CloseableExecutorService)executorService);
- }
- else
- {
- return setExecutor(new CloseableExecutorService(executorService));
- }
- }
-
- /**
- * Sets the executor to publish events; a default executor will be created if not specified.
- */
- public Builder setExecutor(CloseableExecutorService executorService)
- {
this.executorService = checkNotNull(executorService);
return this;
}
@@ -515,7 +499,7 @@
private final TreeNode root;
private final CuratorFramework client;
- private final CloseableExecutorService executorService;
+ private final ExecutorService executorService;
private final boolean cacheData;
private final boolean dataIsCompressed;
private final int maxDepth;
@@ -549,7 +533,7 @@
*/
public TreeCache(CuratorFramework client, String path)
{
- this(client, path, true, false, Integer.MAX_VALUE, new CloseableExecutorService(Executors.newSingleThreadExecutor(defaultThreadFactory), true), false, new DefaultTreeCacheSelector());
+ this(client, path, true, false, Integer.MAX_VALUE, Executors.newSingleThreadExecutor(defaultThreadFactory), false, new DefaultTreeCacheSelector());
}
/**
@@ -561,7 +545,7 @@
* @param createParentNodes true to create parent nodes as containers
* @param selector the selector to use
*/
- TreeCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, int maxDepth, final CloseableExecutorService executorService, boolean createParentNodes, TreeCacheSelector selector)
+ TreeCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, int maxDepth, final ExecutorService executorService, boolean createParentNodes, TreeCacheSelector selector)
{
this.createParentNodes = createParentNodes;
this.selector = Preconditions.checkNotNull(selector, "selector cannot be null");
@@ -604,7 +588,7 @@
{
client.getConnectionStateListenable().removeListener(connectionStateListener);
listeners.clear();
- executorService.close();
+ executorService.shutdown();
try
{
root.wasDeleted();