diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index c676427ee..daeab0112 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -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 + * [HTTPCLIENT-1075] Decompressing entities (DeflateDecompressingEntity, GzipDecompressingEntity) do not correctly handle content streaming. Contributed by James Abley diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java index 5e5b9e350..06272a6e7 100644 --- a/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java +++ b/httpclient/src/main/java/org/apache/http/client/entity/DecompressingEntity.java @@ -85,15 +85,17 @@ abstract class DecompressingEntity extends HttpEntityWrapper { 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(); } }