Skip to content

Commit

Permalink
Merge #1625 into 1.0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
violetagg committed May 7, 2021
2 parents 263ba19 + f6c07bd commit a5b120e
Showing 1 changed file with 10 additions and 2 deletions.
Expand Up @@ -342,9 +342,17 @@ public void onUncaughtException(Connection connection, Throwable error) {
handler.previousRequestHeaders = ops.requestHeaders;
}
}
else if (AbortedException.isConnectionReset(error) && handler.shouldRetry) {
else if (handler.shouldRetry && AbortedException.isConnectionReset(error)) {
HttpClientOperations ops = connection.as(HttpClientOperations.class);
if (ops != null) {
// In some cases the channel close event may be delayed and thus the connection to be
// returned to the pool and later the eviction functionality to remote it from the pool.
// In some rare cases the connection might be acquired immediately, before the channel close
// event and the eviction functionality be able to remove it from the pool, this may lead to I/O
// errors.
// Mark the connection as non-persistent here so that it never be returned to the pool and leave
// the channel close event to invalidate it.
ops.markPersistent(false);
ops.retrying = true;
}
if (log.isDebugEnabled()) {
Expand Down Expand Up @@ -635,7 +643,7 @@ public boolean test(Throwable throwable) {
redirect(re.location);
return true;
}
if (AbortedException.isConnectionReset(throwable) && shouldRetry) {
if (shouldRetry && AbortedException.isConnectionReset(throwable)) {
shouldRetry = false;
redirect(toURI.toString());
return true;
Expand Down

0 comments on commit a5b120e

Please sign in to comment.