@Override protected void doStop() { if (outputSink != null) { try { outputSink.finishWritingAndClose(); } catch (IOException ex) { LOG.warn("Got exception while trying to close OutputSink"); LOG.warn(ex); } } if (this.pool != null) { this.pool.shutdownNow(); try { // wait for 10 sec boolean shutdown = this.pool.awaitTermination(10000, TimeUnit.MILLISECONDS); if (!shutdown) { LOG.warn("Failed to shutdown the thread pool after 10 seconds"); } } catch (InterruptedException e) { LOG.warn("Got interrupted while waiting for the thread pool to shut down" + e); } } if (connection != null) { try { connection.close(); } catch (IOException ex) { LOG.warn("Got exception closing connection :" + ex); } } super.doStop(); }
public void close() { if (connection != null) { try { connection.close(); } catch (Exception ex) { LOG.warn("Could not close the connection: " + ex); } } }