Skip to content

Commit df89f06

Browse files
committed
Mark HTTP/1.1 async connection as not open (non-reusable) as soon as it becomes closed by the opposite endpoint
1 parent a5b00b3 commit df89f06

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

httpcore5/src/main/java/org/apache/hc/core5/http/impl/nio/AbstractHttp1StreamDuplexer.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ private enum ConnectionState { READY, ACTIVE, GRACEFUL_SHUTDOWN, SHUTDOWN}
105105

106106
private volatile ProtocolVersion version;
107107
private volatile EndpointDetails endpointDetails;
108+
private volatile boolean endOfStream;
108109

109110
AbstractHttp1StreamDuplexer(
110111
final ProtocolIOSession ioSession,
@@ -277,13 +278,14 @@ public final void onInput(final ByteBuffer src) throws HttpException, IOExceptio
277278
return;
278279
}
279280

280-
boolean endOfStream = false;
281281
if (incomingMessage == null) {
282282
final int bytesRead = inbuf.fill(ioSession);
283283
if (bytesRead > 0) {
284284
inTransportMetrics.incrementBytesTransferred(bytesRead);
285285
}
286-
endOfStream = bytesRead == -1;
286+
if (bytesRead == -1) {
287+
endOfStream = true;
288+
}
287289
}
288290

289291
do {
@@ -561,7 +563,7 @@ public void close(final CloseMode closeMode) {
561563

562564
@Override
563565
public boolean isOpen() {
564-
return connState.compareTo(ConnectionState.ACTIVE) <= 0;
566+
return connState.compareTo(ConnectionState.ACTIVE) <= 0 && !endOfStream;
565567
}
566568

567569
@Override

0 commit comments

Comments
 (0)