diff --git a/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java b/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java index d9660e2d6..eb4d2ae33 100644 --- a/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java +++ b/module-client/src/main/java/org/apache/http/impl/client/DefaultClientRequestDirector.java @@ -373,13 +373,17 @@ public class DefaultClientRequestDirector if (followup == null) { done = true; } else { - if (this.reuseStrategy.keepAlive(response, context)) { + boolean reuse = reuseStrategy.keepAlive(response, context); + if (reuse) { LOG.debug("Connection kept alive"); // Make sure the response body is fully consumed, if present HttpEntity entity = response.getEntity(); if (entity != null) { entity.consumeContent(); } + // entity consumed above is not an auto-release entity, + // need to mark the connection re-usable explicitly + managedConn.markReusable(); } else { managedConn.close(); }