/** * Closes and flushes the specified {@link Closeable} items. * @param closeables An array of {@link Closeable} items. */ public static void closeQuietly(Closeable... closeables) { closeQuietly(Arrays.asList(closeables)); }
/** * 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); } }
/** * 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); } }