List of usage examples for org.apache.http.impl.nio.conn ManagedClientAsyncConnectionImpl shutdown
@Override public void shutdown() throws IOException
From source file:org.apache.http.impl.nio.conn.PoolingClientAsyncConnectionManager.java
@Override public void releaseConnection(final ManagedClientAsyncConnection conn, final long keepalive, final TimeUnit tunit) { Args.notNull(conn, "HTTP connection"); if (!(conn instanceof ManagedClientAsyncConnectionImpl)) { throw new IllegalArgumentException( "Connection class mismatch, " + "connection not obtained from this manager"); }/*from w w w.j a va 2 s.c om*/ Args.notNull(tunit, "Time unit"); final ManagedClientAsyncConnectionImpl managedConn = (ManagedClientAsyncConnectionImpl) conn; final ClientAsyncConnectionManager manager = managedConn.getManager(); if (manager != null && manager != this) { throw new IllegalArgumentException("Connection not obtained from this manager"); } if (this.pool.isShutdown()) { return; } synchronized (managedConn) { final HttpPoolEntry entry = managedConn.getPoolEntry(); if (entry == null) { return; } try { if (managedConn.isOpen() && !managedConn.isMarkedReusable()) { try { managedConn.shutdown(); } catch (final IOException iox) { if (this.log.isDebugEnabled()) { this.log.debug("I/O exception shutting down released connection", iox); } } } if (managedConn.isOpen()) { entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS); if (this.log.isDebugEnabled()) { String s; if (keepalive > 0) { s = "for " + keepalive + " " + tunit; } else { s = "indefinitely"; } this.log.debug("Connection " + format(entry) + " can be kept alive " + s); } // Do not time out pooled connection managedConn.setSocketTimeout(0); } } finally { this.pool.release(managedConn.detach(), managedConn.isMarkedReusable()); } if (this.log.isDebugEnabled()) { this.log.debug("Connection released: " + format(entry) + formatStats(entry.getRoute())); } } }