hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1420613 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
Date Wed, 12 Dec 2012 10:41:22 GMT
Author: olegk
Date: Wed Dec 12 10:41:20 2012
New Revision: 1420613

URL: http://svn.apache.org/viewvc?rev=1420613&view=rev
Log:
HTTPCLIENT-1273: DecompressingHttpClient does not automatically consume response content in
case of an i/o, HTTP or runtime exception thrown by the decompressing protocol interceptor
leading to a potential connection leak

Modified:
    httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
    httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1420613&r1=1420612&r2=1420613&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Wed Dec 12 10:41:20 2012
@@ -1,6 +1,11 @@
 Changes in trunk
 -------------------
 
+* [HTTPCLIENT-1273] DecompressingHttpClient does not automatically consume response 
+  content in case of an i/o, HTTP or runtime exception thrown by the decompressing 
+  protocol interceptor leading to a potential connection leak. 
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-1080] NTLM dead code commented out.
   Contributed by Karl Wright <DaddyWri at gmail.com>  
 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java?rev=1420613&r1=1420612&r2=1420613&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
(original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java
Wed Dec 12 10:41:20 2012
@@ -155,8 +155,24 @@ public class DecompressingHttpClient imp
             }
             acceptEncodingInterceptor.process(wrapped, context);
             HttpResponse response = backend.execute(target, wrapped, context);
-            contentEncodingInterceptor.process(response, context);
-            return response;
+            try {
+                contentEncodingInterceptor.process(response, context);
+                if (Boolean.TRUE.equals(context.getAttribute(ResponseContentEncoding.UNCOMPRESSED)))
{
+                    response.removeHeaders("Content-Length");
+                    response.removeHeaders("Content-Encoding");
+                    response.removeHeaders("Content-MD5");
+                }
+                return response;
+            } catch (HttpException ex) {
+                EntityUtils.consume(response.getEntity());
+                throw ex;
+            } catch (IOException ex) {
+                EntityUtils.consume(response.getEntity());
+                throw ex;
+            } catch (RuntimeException ex) {
+                EntityUtils.consume(response.getEntity());
+                throw ex;
+            }
         } catch (HttpException e) {
             throw new ClientProtocolException(e);
         }



Mime
View raw message