You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2011/04/11 19:38:38 UTC

svn commit: r1091140 - in /httpcomponents/httpclient/trunk: RELEASE_NOTES.txt httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java

Author: olegk
Date: Mon Apr 11 17:38:37 2011
New Revision: 1091140

URL: http://svn.apache.org/viewvc?rev=1091140&view=rev
Log:
HTTPCLIENT-1078: Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity) do not close content stream in #writeTo() method

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

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1091140&r1=1091139&r2=1091140&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Mon Apr 11 17:38:37 2011
@@ -1,5 +1,9 @@
 Changes since 4.1.1
 
+* [HTTPCLIENT-1078] Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity) 
+  do not close content stream in #writeTo() method.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-1075] Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity) 
   do not correctly handle content streaming.
   Contributed by James Abley <james.abley at gmail.com> 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java?rev=1091140&r1=1091139&r2=1091140&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java Mon Apr 11 17:38:37 2011
@@ -85,15 +85,17 @@ abstract class DecompressingEntity exten
         if (outstream == null) {
             throw new IllegalArgumentException("Output stream may not be null");
         }
-
         InputStream instream = getContent();
+        try {
+            byte[] buffer = new byte[BUFFER_SIZE];
 
-        byte[] buffer = new byte[BUFFER_SIZE];
-
-        int l;
+            int l;
 
-        while ((l = instream.read(buffer)) != -1) {
-            outstream.write(buffer, 0, l);
+            while ((l = instream.read(buffer)) != -1) {
+                outstream.write(buffer, 0, l);
+            }
+        } finally {
+            instream.close();
         }
     }