/** * Performs the cleanup tasks: * 1. closes the InputStream pumper * 2. closes all internally managed closeables (piped streams). * * The order of these tasks can't change or its likely that the pumper will throw errors, * if the stream it uses closes before the pumper it self. */ private void cleanUpOnce() { if (!cleaned.compareAndSet(false, true)) { return; } try { closeQuietly(pumper); shutdownExecutorService(executorService); } finally { closeQuietly(toClose); } }
/** * Performs the cleanup tasks: * 1. closes the InputStream pumper * 2. closes all internally managed closeables (piped streams). * * The order of these tasks can't change or its likely that the pumper will through errors, * if the stream it uses closes before the pumper it self. */ private void cleanUp() { try { if (!closed.compareAndSet(false, true)) { return; } closeQuietly(pumper); shutdownExecutorService(executorService); } finally { closeQuietly(toClose); } }
@Override public void close() { ConnectionPool connectionPool = httpClient.connectionPool(); Dispatcher dispatcher = httpClient.dispatcher(); ExecutorService executorService = httpClient.dispatcher() != null ? httpClient.dispatcher().executorService() : null; if (dispatcher != null) { dispatcher.cancelAll(); } if (connectionPool != null) { connectionPool.evictAll(); } Utils.shutdownExecutorService(executorService); }