tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 57681] Allow parallel class loading in web application class loader by synchronizing on class specific object
Date Tue, 17 Mar 2015 21:42:43 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=57681

--- Comment #8 from Alex Koturanov <koturano@amazon.com> ---
Comment on attachment 32554
  --> https://bz.apache.org/bugzilla/attachment.cgi?id=32554
Patch to work with JDK1.6

--- WebappClassLoader_r1661811.java    2015-03-09 21:53:27.000000000 +0000
+++ WebappClassLoader_patch.java    2015-03-17 14:21:56.000000000 +0000
@@ -1599,7 +1599,25 @@ public class WebappClassLoader
      * @exception ClassNotFoundException if the class was not found
      */
     @Override
-    public synchronized Class<?> loadClass(String name, boolean resolve)
+    public Class<?> loadClass(String name, boolean resolve)
+        throws ClassNotFoundException {
+        // check local cache without entering the global synchronized block
and return if the class is found
+        if (resourceEntries.containsKey(name)) {
+            Class<?> clazz = findLoadedClass0(name);
+            if (clazz != null) {
+                if (log.isDebugEnabled())
+                    log.debug("  Returning class from cache");
+                if (resolve)
+                    resolveClass(clazz);
+                return (clazz);
+            }
+            
+        }
+        // class is not found in local cache - call the original synchronized
method
+        return loadClass0(name, resolve);
+    }
+
+    private synchronized Class<?> loadClass0(String name, boolean resolve)
         throws ClassNotFoundException {

         if (log.isDebugEnabled())

-- 
You are receiving this mail because:
You are the assignee for the bug.

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


Mime
View raw message