Example usage for org.apache.http.impl.conn CPoolProxy detach

List of usage examples for org.apache.http.impl.conn CPoolProxy detach

Introduction

In this page you can find the example usage for org.apache.http.impl.conn CPoolProxy detach.

Prototype

public static CPoolEntry detach(final HttpClientConnection proxy) 

Source Link

Usage

From source file:org.apache.http.impl.conn.PoolingHttpClientConnectionManager.java

public void releaseConnection(final HttpClientConnection managedConn, final Object state, final long keepalive,
        final TimeUnit tunit) {
    Args.notNull(managedConn, "Managed connection");
    synchronized (managedConn) {
        final CPoolEntry entry = CPoolProxy.detach(managedConn);
        if (entry == null) {
            return;
        }/* w w w .j  ava2 s  .co  m*/
        final ManagedHttpClientConnection conn = entry.getConnection();
        try {
            if (conn.isOpen()) {
                entry.setState(state);
                entry.updateExpiry(keepalive, tunit != null ? tunit : TimeUnit.MILLISECONDS);
                if (this.log.isDebugEnabled()) {
                    final String s;
                    if (keepalive > 0) {
                        s = "for " + (double) keepalive / 1000 + " seconds";
                    } else {
                        s = "indefinitely";
                    }
                    this.log.debug("Connection " + format(entry) + " can be kept alive " + s);
                }
            }
        } finally {
            this.pool.release(entry, conn.isOpen() && entry.isRouteComplete());
            if (this.log.isDebugEnabled()) {
                this.log.debug("Connection released: " + format(entry) + formatStats(entry.getRoute()));
            }
        }
    }
}