From a7cf25e509e0ed7f69661e3fc7b3becf4a185c0b Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 16 Sep 2009 04:11:21 +0000 Subject: [PATCH] Close all input streams when unzipping, Submitted by David Schlosnagle, PR 42696 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@815599 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/taskdefs/Expand.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java index a48281d05..ed7c6f2ea 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ b/src/main/org/apache/tools/ant/taskdefs/Expand.java @@ -173,9 +173,15 @@ public class Expand extends Task { while (e.hasMoreElements()) { empty = false; ZipEntry ze = (ZipEntry) 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");