diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2011-11-30 17:17:59 -0800 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2011-11-30 17:45:41 -0800 |
commit | 0d61707f12b5b1a94b325fc8c2975a9e60a14dac (patch) | |
tree | 38616634067dda94e08944faca52753268d5ac4f /org.eclipse.jgit.http.server | |
parent | cea935ab1b6caf52b31dfd4eae9696dfcc0593a2 (diff) | |
download | jgit-0d61707f12b5b1a94b325fc8c2975a9e60a14dac.tar.gz jgit-0d61707f12b5b1a94b325fc8c2975a9e60a14dac.zip |
Always close the GZIPOutputStream to release Deflater
The stream must be closed to ensure the native resources associated
with its internal Deflater instance are cleaned up early, instead of
waiting for GC to identify the dead object and finialize it.
Change-Id: Ic31b5df563f19404ed4682556999f4332aa61562
Diffstat (limited to 'org.eclipse.jgit.http.server')
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java index 00cb67ca95..c39b78900d 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/SmartOutputStream.java @@ -101,8 +101,11 @@ class SmartOutputStream extends TemporaryBuffer { TemporaryBuffer gzbuf = new TemporaryBuffer.Heap(LIMIT); try { GZIPOutputStream gzip = new GZIPOutputStream(gzbuf); - out.writeTo(gzip, null); - gzip.close(); + try { + out.writeTo(gzip, null); + } finally { + gzip.close(); + } if (gzbuf.length() < out.length()) { out = gzbuf; rsp.setHeader(HDR_CONTENT_ENCODING, ENCODING_GZIP); |