diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java index 463d19f8c..7e9ed483d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Jar.java +++ b/src/main/org/apache/tools/ant/taskdefs/Jar.java @@ -163,8 +163,9 @@ public class Jar extends Zip { public void setDestFile(File jarFile) { super.setDestFile(jarFile); if (jarFile.exists()) { + ZipFile zf = null; try { - ZipFile zf = new ZipFile(jarFile); + zf = new ZipFile(jarFile); // must not use getEntry as "well behaving" applications // must accept the manifest in any capitalization @@ -174,13 +175,22 @@ public class Jar extends Zip { if (ze.getName().equalsIgnoreCase("META-INF/MANIFEST.MF")) { originalManifest = getManifest(new InputStreamReader(zf - .getInputStream(ze))); + .getInputStream(ze))); } } } catch (Throwable t) { log("error while reading original manifest: " + t.getMessage(), Project.MSG_WARN); + } finally { + if (zf != null) { + try { + zf.close(); + } catch (IOException e) { + // XXX - log an error? throw an exception? + } + } } + } }