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 2013/04/18 11:15:00 UTC

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

Author: olegk
Date: Thu Apr 18 09:15:00 2013
New Revision: 1469235

URL: http://svn.apache.org/r1469235
Log:
HTTPCLIENT-1341] DeflateDecompressingEntity does not call Inflater#end

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

Modified: httpcomponents/httpclient/trunk/RELEASE_NOTES.txt
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/RELEASE_NOTES.txt?rev=1469235&r1=1469234&r2=1469235&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/RELEASE_NOTES.txt (original)
+++ httpcomponents/httpclient/trunk/RELEASE_NOTES.txt Thu Apr 18 09:15:00 2013
@@ -1,6 +1,9 @@
 Changes since release 4.3 BETA1
 -------------------
 
+* [HTTPCLIENT-1341] DeflateDecompressingEntity does not call Inflater#end.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
 * [HTTPCLIENT-1299] (regression) cache incorrectly disposes of the underlying cache resource 
   when storing variant entry.
   Contributed by James Leigh <james at 3roundstones.com> 

Modified: httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java?rev=1469235&r1=1469234&r2=1469235&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java (original)
+++ httpcomponents/httpclient/trunk/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java Thu Apr 18 09:15:00 2013
@@ -142,13 +142,15 @@ public class DeflateDecompressingEntity 
              * and return an unused InputStream now.
              */
             pushback.unread(peeked, 0, headerLength);
-            return new InflaterInputStream(pushback);
+            return new DeflateStream(pushback, new Inflater());
         } catch (final DataFormatException e) {
 
             /* Presume that it's an RFC1951 deflate stream rather than RFC1950 zlib stream and try
              * again. */
             pushback.unread(peeked, 0, headerLength);
-            return new InflaterInputStream(pushback, new Inflater(true));
+            return new DeflateStream(pushback, new Inflater(true));
+        } finally {
+            inf.end();
         }
     }
 
@@ -172,4 +174,24 @@ public class DeflateDecompressingEntity 
         return -1;
     }
 
+    static class DeflateStream extends InflaterInputStream {
+
+        private boolean closed = false;
+
+        public DeflateStream(final InputStream in, final Inflater inflater) {
+            super(in, inflater);
+        }
+
+        @Override
+        public void close() throws IOException {
+            if (closed) {
+                return;
+            }
+            closed = true;
+            inf.end();
+            super.close();
+        }
+
+    }
+
 }