Browse Source

Close original archive after checking for old manifest in <jar> -

otherwise the file may still be locked on Windows and friends when we
try to rename it.

Submitted by:	Antoine Levy-Lambert <levylambert at tiscali dash dsl dot de>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@273965 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
773a2273ed
1 changed files with 12 additions and 2 deletions
  1. +12
    -2
      src/main/org/apache/tools/ant/taskdefs/Jar.java

+ 12
- 2
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -163,8 +163,9 @@ public class Jar extends Zip {
public void setDestFile(File jarFile) { public void setDestFile(File jarFile) {
super.setDestFile(jarFile); super.setDestFile(jarFile);
if (jarFile.exists()) { if (jarFile.exists()) {
ZipFile zf = null;
try { try {
ZipFile zf = new ZipFile(jarFile);
zf = new ZipFile(jarFile);


// must not use getEntry as "well behaving" applications // must not use getEntry as "well behaving" applications
// must accept the manifest in any capitalization // must accept the manifest in any capitalization
@@ -174,13 +175,22 @@ public class Jar extends Zip {
if (ze.getName().equalsIgnoreCase("META-INF/MANIFEST.MF")) { if (ze.getName().equalsIgnoreCase("META-INF/MANIFEST.MF")) {
originalManifest = originalManifest =
getManifest(new InputStreamReader(zf getManifest(new InputStreamReader(zf
.getInputStream(ze)));
.getInputStream(ze)));
} }
} }
} catch (Throwable t) { } catch (Throwable t) {
log("error while reading original manifest: " + t.getMessage(), log("error while reading original manifest: " + t.getMessage(),
Project.MSG_WARN); Project.MSG_WARN);
} finally {
if (zf != null) {
try {
zf.close();
} catch (IOException e) {
// XXX - log an error? throw an exception?
}
}
} }
} }
} }




Loading…
Cancel
Save