From 4d40bbed3c07f5059bf117902bd43661260cf03a Mon Sep 17 00:00:00 2001 From: Olivier Liegeon Date: Mon, 19 Sep 2016 15:15:49 -0500 Subject: [PATCH] CURATOR-350 allow to close executor service on shutdown if you pass your executor service when creating you service, you still want to be able to decide wether it should be close on shutdown or not --- .../recipes/cache/PathChildrenCache.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java index 568d03d3dc..fa0e447ab1 100644 --- a/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java +++ b/curator-recipes/src/main/java/org/apache/curator/framework/recipes/cache/PathChildrenCache.java @@ -206,7 +206,20 @@ public PathChildrenCache(CuratorFramework client, String path, boolean cacheData */ public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, final ExecutorService executorService) { - this(client, path, cacheData, dataIsCompressed, new CloseableExecutorService(executorService)); + this(client, path, cacheData, dataIsCompressed, executorService, false); + } + + /** + * @param client the client + * @param path path to watch + * @param cacheData if true, node contents are cached in addition to the stat + * @param dataIsCompressed if true, data in the path is compressed + * @param executorService ExecutorService to use for the PathChildrenCache's background thread. This service should be single threaded, otherwise the cache may see inconsistent results. + * @param shutdownOnClose if true, shutdown the executor service when this is closed + */ + public PathChildrenCache(CuratorFramework client, String path, boolean cacheData, boolean dataIsCompressed, final ExecutorService executorService, boolean shutdownOnClose) + { + this(client, path, cacheData, dataIsCompressed, new CloseableExecutorService(executorService, shutdownOnClose)); } /**