Close all input streams when unzipping, Submitted by David Schlosnagle, PR 42696 - merge from Ant core
git-svn-id: https://svn.apache.org/repos/asf/ant/sandbox/antlibs/compress/trunk@815601 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/org/apache/ant/compress/taskdefs/Unzip.java b/src/main/org/apache/ant/compress/taskdefs/Unzip.java
index 4cbe2b6..4c63e4c 100644
--- a/src/main/org/apache/ant/compress/taskdefs/Unzip.java
+++ b/src/main/org/apache/ant/compress/taskdefs/Unzip.java
@@ -64,9 +64,15 @@
while (e.hasMoreElements()) {
empty = false;
ZipArchiveEntry ze = (ZipArchiveEntry) e.nextElement();
- extractFile(fileUtils, srcF, dir, zf.getInputStream(ze),
- ze.getName(), new Date(ze.getTime()),
- ze.isDirectory(), mapper);
+ InputStream is = null;
+ try {
+ extractFile(fileUtils, srcF, dir,
+ is = zf.getInputStream(ze),
+ ze.getName(), new Date(ze.getTime()),
+ ze.isDirectory(), mapper);
+ } finally {
+ FileUtils.close(is);
+ }
}
if (empty && getFailOnEmptyArchive()) {
throw new BuildException("archive '" + srcF + "' is empty");