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");