ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r533498 - in /ant/core/trunk: CONTRIBUTORS WHATSNEW src/main/org/apache/tools/ant/AntClassLoader.java
Date Sun, 29 Apr 2007 13:00:17 GMT
Author: jkf
Date: Sun Apr 29 06:00:17 2007
New Revision: 533498

URL: http://svn.apache.org/viewvc?view=rev&rev=533498
Log:
Pr: 42259 inspired on optimization suggested by Tom Brus

Modified:
    ant/core/trunk/CONTRIBUTORS
    ant/core/trunk/WHATSNEW
    ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java

Modified: ant/core/trunk/CONTRIBUTORS
URL: http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?view=diff&rev=533498&r1=533497&r2=533498
==============================================================================
Binary files - no diff available.

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?view=diff&rev=533498&r1=533497&r2=533498
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Apr 29 06:00:17 2007
@@ -11,6 +11,9 @@
 
 Fixed bugs:
 -----------
+* Improvements in AntClassLoader Speed.
+  Bugzilla report 42259
+
 * Error in handling of some permissions, most notably the AllPermission on
   jdk 1.5
   Bugzilla report 41776

Modified: ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java?view=diff&rev=533498&r1=533497&r2=533498
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/AntClassLoader.java Sun Apr 29 06:00:17 2007
@@ -812,22 +812,22 @@
      */
     private InputStream getResourceStream(File file, String resourceName) {
         try {
-            if (!file.exists()) {
-                return null;
-            }
-
-            if (file.isDirectory()) {
+            ZipFile zipFile = (ZipFile) zipFiles.get(file);
+            if (zipFile == null && file.isDirectory()) {
                 File resource = new File(file, resourceName);
 
                 if (resource.exists()) {
                     return new FileInputStream(resource);
                 }
             } else {
-                // is the zip file in the cache
-                ZipFile zipFile = (ZipFile) zipFiles.get(file);
                 if (zipFile == null) {
-                    zipFile = new ZipFile(file);
-                    zipFiles.put(file, zipFile);
+                    if (file.exists()) {
+
+                        zipFile = new ZipFile(file);
+                        zipFiles.put(file, zipFile);
+                    } else {
+                        return null;
+                    }
                     //to eliminate a race condition, retrieve the entry
                     //that is in the hash table under that filename
                     zipFile = (ZipFile) zipFiles.get(file);
@@ -838,23 +838,24 @@
                 }
             }
         } catch (Exception e) {
-            log("Ignoring Exception " + e.getClass().getName()
-                + ": " + e.getMessage() + " reading resource " + resourceName
-                + " from " + file, Project.MSG_VERBOSE);
+            log("Ignoring Exception " + e.getClass().getName() + ": "
+                    + e.getMessage() + " reading resource " + resourceName
+                    + " from " + file, Project.MSG_VERBOSE);
         }
 
         return null;
     }
 
     /**
-     * Tests whether or not the parent classloader should be checked for
-     * a resource before this one. If the resource matches both the
-     * "use parent classloader first" and the "use this classloader first"
-     * lists, the latter takes priority.
-     *
-     * @param resourceName The name of the resource to check.
-     *                     Must not be <code>null</code>.
-     *
+     * Tests whether or not the parent classloader should be checked for a
+     * resource before this one. If the resource matches both the "use parent
+     * classloader first" and the "use this classloader first" lists, the latter
+     * takes priority.
+     * 
+     * @param resourceName
+     *            The name of the resource to check. Must not be
+     *            <code>null</code>.
+     * 
      * @return whether or not the parent classloader should be checked for a
      *         resource before this one is.
      */
@@ -1010,11 +1011,8 @@
      */
     protected URL getResourceURL(File file, String resourceName) {
         try {
-            if (!file.exists()) {
-                return null;
-            }
-
-            if (file.isDirectory()) {
+            ZipFile zipFile = (ZipFile) zipFiles.get(file);
+            if (zipFile == null && file.isDirectory()) {
                 File resource = new File(file, resourceName);
 
                 if (resource.exists()) {
@@ -1025,12 +1023,14 @@
                     }
                 }
             } else {
-                ZipFile zipFile = (ZipFile) zipFiles.get(file);
                 if (zipFile == null) {
-                    zipFile = new ZipFile(file);
-                    zipFiles.put(file, zipFile);
+                    if (file.exists()) {
+                        zipFile = new ZipFile(file);
+                        zipFiles.put(file, zipFile);
+                    } else {
+                        return null;
+                    }
                 }
-
                 ZipEntry entry = zipFile.getEntry(resourceName);
                 if (entry != null) {
                     try {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message