in httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/BasicHttpClientConnectionManager.java [335:377]
public synchronized void release(final ConnectionEndpoint endpoint, final Object state, final TimeValue keepAlive) {
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) {
this.conn.close(CloseMode.GRACEFUL);
}
this.updated = System.currentTimeMillis();
if (!this.conn.isOpen() && !this.conn.isConsistent()) {
this.route = null;
this.conn = null;
this.expiry = Long.MAX_VALUE;
if (LOG.isDebugEnabled()) {
LOG.debug("{} Connection is not kept alive", id);
}
} else {
this.state = state;
if (conn != null) {
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;
}
}
} finally {
this.leased = false;
}
}