public void release()

in httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java [422:467]


    public void release(final ConnectionEndpoint endpoint, final Object state, final TimeValue keepAlive) {
        lock.lock();
        try {
            Args.notNull(endpoint, "Managed endpoint");
            final InternalConnectionEndpoint internalEndpoint = cast(endpoint);
            final ManagedHttpClientConnection conn = internalEndpoint.detach();
            if (LOG.isDebugEnabled()) {
                LOG.debug("{} Releasing connection {}", id, conn);
            }
            if (isClosed()) {
                return;
            }
            try {
                if (keepAlive == null && conn != null) {
                    conn.close(CloseMode.GRACEFUL);
                }
                this.updated = System.currentTimeMillis();
                if (conn != null && conn.isOpen() && conn.isConsistent()) {
                    this.state = state;
                    conn.passivate();
                    if (TimeValue.isPositive(keepAlive)) {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("{} Connection can be kept alive for {}", id, keepAlive);
                        }
                        this.expiry = this.updated + keepAlive.toMilliseconds();
                    } else {
                        if (LOG.isDebugEnabled()) {
                            LOG.debug("{} Connection can be kept alive indefinitely", id);
                        }
                        this.expiry = Long.MAX_VALUE;
                    }
                } else {
                    this.route = null;
                    this.conn = null;
                    this.expiry = Long.MAX_VALUE;
                    if (LOG.isDebugEnabled()) {
                        LOG.debug("{} Connection is not kept alive", id);
                    }
                }
            } finally {
                this.leased = false;
            }
        } finally {
            lock.unlock();
        }
    }