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();