@Override public void close() throws Exception { if (!closed) { closed = true; logger.info("Stopping ZKClusterClient"); initialConnection.countDown(); // discovery attempts to close its caches(ie serviceCache) already. however, being good citizens we make sure to // explicitly close serviceCache. Not only that we make sure to close serviceCache before discovery to prevent // double releasing and disallowing jvm to spit bothering warnings. simply put, we are great! AutoCloseables.close(discovery, curator, CloseableSchedulerThreadPool.of(executorService, logger)); logger.info("Stopped ZKClusterClient"); } }