mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-22 03:54:33 +02:00
8221395: HttpClient leaving connections in CLOSE_WAIT state until Java process ends
When a non WebSocket connection is not returned to the pool, it needs to be closed even if HttpConnection::isOpen yields false. Reviewed-by: chegar, michaelm
This commit is contained in:
parent
76cdc8016f
commit
47b9d898ab
3 changed files with 232 additions and 18 deletions
|
@ -317,14 +317,13 @@ abstract class HttpConnection implements Closeable {
|
|||
void closeOrReturnToCache(HttpHeaders hdrs) {
|
||||
if (hdrs == null) {
|
||||
// the connection was closed by server, eof
|
||||
Log.logTrace("Cannot return connection to pool: closing {0}", this);
|
||||
close();
|
||||
return;
|
||||
}
|
||||
if (!isOpen()) {
|
||||
return;
|
||||
}
|
||||
HttpClientImpl client = client();
|
||||
if (client == null) {
|
||||
Log.logTrace("Client released: closing {0}", this);
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
@ -333,10 +332,12 @@ abstract class HttpConnection implements Closeable {
|
|||
.map((s) -> !s.equalsIgnoreCase("close"))
|
||||
.orElse(true);
|
||||
|
||||
if (keepAlive) {
|
||||
if (keepAlive && isOpen()) {
|
||||
Log.logTrace("Returning connection to the pool: {0}", this);
|
||||
pool.returnToPool(this);
|
||||
} else {
|
||||
Log.logTrace("Closing connection (keepAlive={0}, isOpen={1}): {2}",
|
||||
keepAlive, isOpen(), this);
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue