From 1b063abfa9e10933f1be79a589fae3464f1e36a5 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Tue, 8 May 2012 19:54:27 +0000 Subject: [PATCH] HTTPCLIENT-1187: If a revalidation response is deemed too old CachingHttpClient fails to consume its content resulting in a connection leak git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1335726 13f79535-47bb-0310-9956-ffa450edef68 --- RELEASE_NOTES.txt | 4 ++++ .../org/apache/http/impl/client/cache/CachingHttpClient.java | 2 ++ 2 files changed, 6 insertions(+) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index dad0f16bb..ed66de857 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,6 +1,10 @@ Changes since 4.2 BETA1 ------------------- +* [HTTPCLIENT-1187] If a revalidation response is deemed too old CachingHttpClient fails to + consume its content resulting in a connection leak. + Contributed by Oleg Kalnichevski + * [HTTPCLIENT-1186] State of newly created connections in the connection pool is not always correctly updated potentially allowing those connections to be leased to users with a different security context. diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java index 99d32281d..409a89260 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java @@ -769,6 +769,7 @@ public class CachingHttpClient implements HttpClient { HttpCacheEntry matchedEntry = matchingVariant.getEntry(); if (revalidationResponseIsTooOld(backendResponse, matchedEntry)) { + EntityUtils.consume(backendResponse.getEntity()); return retryRequestUnconditionally(target, request, context, matchedEntry); } @@ -839,6 +840,7 @@ public class CachingHttpClient implements HttpClient { Date responseDate = getCurrentDate(); if (revalidationResponseIsTooOld(backendResponse, cacheEntry)) { + EntityUtils.consume(backendResponse.getEntity()); HttpRequest unconditional = conditionalRequestBuilder .buildUnconditionalRequest(request, cacheEntry); requestDate = getCurrentDate();