From 88e48dbdd378dbb095a7537d430e400cd785532c Mon Sep 17 00:00:00 2001 From: Steve Loughran Date: Fri, 27 Apr 2007 20:40:13 +0000 Subject: [PATCH] little bit of code review git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@533214 13f79535-47bb-0310-9956-ffa450edef68 --- src/main/org/apache/tools/ant/AntClassLoader.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index 9afe07b9e..90462240a 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -35,6 +35,7 @@ import java.util.Hashtable; import java.util.Map; import java.util.StringTokenizer; import java.util.Vector; +import java.util.Locale; import java.util.jar.Attributes; import java.util.jar.Attributes.Name; import java.util.jar.JarFile; @@ -212,7 +213,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { */ private Hashtable zipFiles = new Hashtable(); - /** Static map of jar file/time to manifiest class-path entries */ + /** Static map of jar file/time to manifest class-path entries */ private static Map/**/ pathMap = Collections.synchronizedMap(new HashMap()); /** @@ -515,9 +516,7 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { } catch (org.apache.tools.ant.taskdefs.ManifestException e) { // ignore } finally { - if (manifestStream != null) { - manifestStream.close(); - } + FileUtils.close(manifestStream); if (jarFile != null) { jarFile.close(); } @@ -829,6 +828,9 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { if (zipFile == null) { zipFile = new ZipFile(file); zipFiles.put(file, zipFile); + //to eliminate a race condition, retrieve the entry + //that is in the hash table under that filename + zipFile = (ZipFile) zipFiles.get(file); } ZipEntry entry = zipFile.getEntry(resourceName); if (entry != null) { @@ -1276,7 +1278,8 @@ public class AntClassLoader extends ClassLoader implements SubBuildListener { } } - if (sealedString != null && sealedString.equalsIgnoreCase("true")) { + if (sealedString != null + && sealedString.toLowerCase(Locale.ENGLISH).equals("true")) { try { sealBase = new URL(FileUtils.getFileUtils().toURI(container.getAbsolutePath())); } catch (MalformedURLException e) {