From 4d8e7981560262f5bcb4b183f8836e1c2cfa29e0 Mon Sep 17 00:00:00 2001 From: Roland Weber Date: Thu, 13 Dec 2007 04:09:47 +0000 Subject: [PATCH] fixed connection reuse bug, see HTTPCLIENT-711 git-svn-id: https://svn.apache.org/repos/asf/jakarta/httpcomponents/httpclient/trunk@603812 13f79535-47bb-0310-9956-ffa450edef68 --- .../http/impl/client/DefaultClientRequestDirector.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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(); }