Skip to content

Commit a5b120e

Browse files
committedMay 7, 2021
Merge #1625 into 1.0.7
2 parents 263ba19 + f6c07bd commit a5b120e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed
 

‎reactor-netty-http/src/main/java/reactor/netty/http/client/HttpClientConnect.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,17 @@ public void onUncaughtException(Connection connection, Throwable error) {
342342
handler.previousRequestHeaders = ops.requestHeaders;
343343
}
344344
}
345-
else if (AbortedException.isConnectionReset(error) && handler.shouldRetry) {
345+
else if (handler.shouldRetry && AbortedException.isConnectionReset(error)) {
346346
HttpClientOperations ops = connection.as(HttpClientOperations.class);
347347
if (ops != null) {
348+
// In some cases the channel close event may be delayed and thus the connection to be
349+
// returned to the pool and later the eviction functionality to remote it from the pool.
350+
// In some rare cases the connection might be acquired immediately, before the channel close
351+
// event and the eviction functionality be able to remove it from the pool, this may lead to I/O
352+
// errors.
353+
// Mark the connection as non-persistent here so that it never be returned to the pool and leave
354+
// the channel close event to invalidate it.
355+
ops.markPersistent(false);
348356
ops.retrying = true;
349357
}
350358
if (log.isDebugEnabled()) {
@@ -635,7 +643,7 @@ public boolean test(Throwable throwable) {
635643
redirect(re.location);
636644
return true;
637645
}
638-
if (AbortedException.isConnectionReset(throwable) && shouldRetry) {
646+
if (shouldRetry && AbortedException.isConnectionReset(throwable)) {
639647
shouldRetry = false;
640648
redirect(toURI.toString());
641649
return true;

0 commit comments

Comments
 (0)
Please sign in to comment.