From c4c9d2552b9c8ce227f600205c93ae6dabd5036b Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 13 Jul 2011 13:44:20 +0000 Subject: [PATCH] clean up Inflater instance as some JDKs won't do it for us. PR 42696. Submitted by Mounir git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1146020 13f79535-47bb-0310-9956-ffa450edef68 --- CONTRIBUTORS | 1 + WHATSNEW | 4 ++++ contributors.xml | 3 +++ src/main/org/apache/tools/zip/ZipFile.java | 8 +++++++- 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 0c24b7468..256a851d1 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -238,6 +238,7 @@ Miha Mike Davis Mike Roberts mnowostawski +Mounir Nathan Beyer Nick Chalko Nick Fortescue diff --git a/WHATSNEW b/WHATSNEW index 1aab08cd3..5c1eaec42 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -55,6 +55,10 @@ Fixed bugs: error output stream some "Pipe broken" errors. Bugzilla Report 48789. + * ZipFile failed to clean up some resources which could lead to + OutOfMemoryException while unzipping large archives. + Bugzilla Report 42969. + Other changes: -------------- diff --git a/contributors.xml b/contributors.xml index f0bf380dc..d68bbcc3c 100644 --- a/contributors.xml +++ b/contributors.xml @@ -976,6 +976,9 @@ mnowostawski + + Mounir + Nathan Beyer diff --git a/src/main/org/apache/tools/zip/ZipFile.java b/src/main/org/apache/tools/zip/ZipFile.java index acb6f3d1b..074792018 100644 --- a/src/main/org/apache/tools/zip/ZipFile.java +++ b/src/main/org/apache/tools/zip/ZipFile.java @@ -269,7 +269,13 @@ public class ZipFile { return bis; case ZipEntry.DEFLATED: bis.addDummy(); - return new InflaterInputStream(bis, new Inflater(true)); + final Inflater inflater = new Inflater(true); + return new InflaterInputStream(bis, inflater) { + public void close() throws IOException { + super.close(); + inflater.end(); + } + }; default: throw new ZipException("Found unsupported compression method " + ze.getMethod());