[pkg-java] r12532 - in trunk/tomcat6/debian: . patches

Marcus Better marcusb-guest at alioth.debian.org
Mon May 31 13:51:29 UTC 2010


Author: marcusb-guest
Date: 2010-05-31 13:51:25 +0000 (Mon, 31 May 2010)
New Revision: 12532

Added:
   trunk/tomcat6/debian/patches/webapp-classloader-deadlock-fix.patch
Modified:
   trunk/tomcat6/debian/changelog
   trunk/tomcat6/debian/patches/series
Log:
Apply upstream fix for deadlock in WebappClassLoader. (Closes: #583896)

Modified: trunk/tomcat6/debian/changelog
===================================================================
--- trunk/tomcat6/debian/changelog	2010-05-30 20:05:33 UTC (rev 12531)
+++ trunk/tomcat6/debian/changelog	2010-05-31 13:51:25 UTC (rev 12532)
@@ -1,3 +1,9 @@
+tomcat6 (6.0.26-3) UNRELEASED; urgency=low
+
+  * Apply upstream fix for deadlock in WebappClassLoader. (Closes: #583896)
+
+ -- Marcus Better <marcus at better.se>  Mon, 31 May 2010 15:50:57 +0200
+
 tomcat6 (6.0.26-2) unstable; urgency=low
 
   * debian/tomcat6.{postinst,prerm}: Respect TOMCAT6_USER and TOMCAT6_GROUP

Modified: trunk/tomcat6/debian/patches/series
===================================================================
--- trunk/tomcat6/debian/patches/series	2010-05-30 20:05:33 UTC (rev 12531)
+++ trunk/tomcat6/debian/patches/series	2010-05-31 13:51:25 UTC (rev 12532)
@@ -7,3 +7,4 @@
 servlet-api-OSGi.patch
 jsp-api-OSGi.patch
 allow-empty-pid-file.patch
+webapp-classloader-deadlock-fix.patch

Added: trunk/tomcat6/debian/patches/webapp-classloader-deadlock-fix.patch
===================================================================
--- trunk/tomcat6/debian/patches/webapp-classloader-deadlock-fix.patch	                        (rev 0)
+++ trunk/tomcat6/debian/patches/webapp-classloader-deadlock-fix.patch	2010-05-31 13:51:25 UTC (rev 12532)
@@ -0,0 +1,275 @@
+Index: trunk/java/org/apache/jasper/servlet/JasperLoader.java
+===================================================================
+--- trunk/java/org/apache/jasper/servlet/JasperLoader.java	(revision 941867)
++++ trunk/java/org/apache/jasper/servlet/JasperLoader.java	(revision 941868)
+@@ -91,7 +91,7 @@
+      *                                     
+      * @exception ClassNotFoundException if the class was not found
+      */                                    
+-    public Class loadClass(final String name, boolean resolve)
++    public synchronized Class loadClass(final String name, boolean resolve)
+         throws ClassNotFoundException {
+ 
+         Class clazz = null;                
+@@ -169,4 +169,4 @@
+     public final PermissionCollection getPermissions(CodeSource codeSource) {
+         return permissionCollection;
+     }
+-}
+\ No newline at end of file
++}
+Index: trunk/java/org/apache/catalina/loader/ResourceEntry.java
+===================================================================
+--- trunk/java/org/apache/catalina/loader/ResourceEntry.java	(revision 941867)
++++ trunk/java/org/apache/catalina/loader/ResourceEntry.java	(revision 941868)
+@@ -47,7 +47,7 @@
+     /**
+      * Loaded class.
+      */
+-    public Class loadedClass = null;
++    public volatile Class loadedClass = null;
+ 
+ 
+     /**
+Index: trunk/java/org/apache/catalina/loader/WebappClassLoader.java
+===================================================================
+--- trunk/java/org/apache/catalina/loader/WebappClassLoader.java	(revision 941867)
++++ trunk/java/org/apache/catalina/loader/WebappClassLoader.java	(revision 941868)
+@@ -1432,102 +1432,121 @@
+      *
+      * @exception ClassNotFoundException if the class was not found
+      */
+-    public Class loadClass(String name, boolean resolve)
++    public synchronized Class loadClass(String name, boolean resolve)
+         throws ClassNotFoundException {
+ 
+-        synchronized (name.intern()) {
+-            if (log.isDebugEnabled())
+-                log.debug("loadClass(" + name + ", " + resolve + ")");
+-            Class clazz = null;
+-    
+-            // Log access to stopped classloader
+-            if (!started) {
+-                try {
+-                    throw new IllegalStateException();
+-                } catch (IllegalStateException e) {
+-                    log.info(sm.getString("webappClassLoader.stopped", name), e);
+-                }
++        if (log.isDebugEnabled())
++            log.debug("loadClass(" + name + ", " + resolve + ")");
++        Class clazz = null;
++
++        // Log access to stopped classloader
++        if (!started) {
++            try {
++                throw new IllegalStateException();
++            } catch (IllegalStateException e) {
++                log.info(sm.getString("webappClassLoader.stopped", name), e);
+             }
+-    
+-            // (0) Check our previously loaded local class cache
+-            clazz = findLoadedClass0(name);
++        }
++
++        // (0) Check our previously loaded local class cache
++        clazz = findLoadedClass0(name);
++        if (clazz != null) {
++            if (log.isDebugEnabled())
++                log.debug("  Returning class from cache");
++            if (resolve)
++                resolveClass(clazz);
++            return (clazz);
++        }
++
++        // (0.1) Check our previously loaded class cache
++        clazz = findLoadedClass(name);
++        if (clazz != null) {
++            if (log.isDebugEnabled())
++                log.debug("  Returning class from cache");
++            if (resolve)
++                resolveClass(clazz);
++            return (clazz);
++        }
++
++        // (0.2) Try loading the class with the system class loader, to prevent
++        //       the webapp from overriding J2SE classes
++        try {
++            clazz = system.loadClass(name);
+             if (clazz != null) {
+-                if (log.isDebugEnabled())
+-                    log.debug("  Returning class from cache");
+                 if (resolve)
+                     resolveClass(clazz);
+                 return (clazz);
+             }
+-    
+-            // (0.1) Check our previously loaded class cache
+-            clazz = findLoadedClass(name);
+-            if (clazz != null) {
+-                if (log.isDebugEnabled())
+-                    log.debug("  Returning class from cache");
+-                if (resolve)
+-                    resolveClass(clazz);
+-                return (clazz);
++        } catch (ClassNotFoundException e) {
++            // Ignore
++        }
++
++        // (0.5) Permission to access this class when using a SecurityManager
++        if (securityManager != null) {
++            int i = name.lastIndexOf('.');
++            if (i >= 0) {
++                try {
++                    securityManager.checkPackageAccess(name.substring(0,i));
++                } catch (SecurityException se) {
++                    String error = "Security Violation, attempt to use " +
++                        "Restricted Class: " + name;
++                    log.info(error, se);
++                    throw new ClassNotFoundException(error, se);
++                }
+             }
+-    
+-            // (0.2) Try loading the class with the system class loader, to prevent
+-            //       the webapp from overriding J2SE classes
++        }
++
++        boolean delegateLoad = delegate || filter(name);
++
++        // (1) Delegate to our parent if requested
++        if (delegateLoad) {
++            if (log.isDebugEnabled())
++                log.debug("  Delegating to parent classloader1 " + parent);
++            ClassLoader loader = parent;
++            if (loader == null)
++                loader = system;
+             try {
+-                clazz = system.loadClass(name);
++                clazz = loader.loadClass(name);
+                 if (clazz != null) {
++                    if (log.isDebugEnabled())
++                        log.debug("  Loading class from parent");
+                     if (resolve)
+                         resolveClass(clazz);
+                     return (clazz);
+                 }
+             } catch (ClassNotFoundException e) {
+-                // Ignore
++                ;
+             }
+-    
+-            // (0.5) Permission to access this class when using a SecurityManager
+-            if (securityManager != null) {
+-                int i = name.lastIndexOf('.');
+-                if (i >= 0) {
+-                    try {
+-                        securityManager.checkPackageAccess(name.substring(0,i));
+-                    } catch (SecurityException se) {
+-                        String error = "Security Violation, attempt to use " +
+-                            "Restricted Class: " + name;
+-                        log.info(error, se);
+-                        throw new ClassNotFoundException(error, se);
+-                    }
+-                }
+-            }
+-    
+-            boolean delegateLoad = delegate || filter(name);
+-    
+-            // (1) Delegate to our parent if requested
+-            if (delegateLoad) {
++        }
++
++        // (2) Search local repositories
++        if (log.isDebugEnabled())
++            log.debug("  Searching local repositories");
++        try {
++            clazz = findClass(name);
++            if (clazz != null) {
+                 if (log.isDebugEnabled())
+-                    log.debug("  Delegating to parent classloader1 " + parent);
+-                ClassLoader loader = parent;
+-                if (loader == null)
+-                    loader = system;
+-                try {
+-                    clazz = loader.loadClass(name);
+-                    if (clazz != null) {
+-                        if (log.isDebugEnabled())
+-                            log.debug("  Loading class from parent");
+-                        if (resolve)
+-                            resolveClass(clazz);
+-                        return (clazz);
+-                    }
+-                } catch (ClassNotFoundException e) {
+-                    ;
+-                }
++                    log.debug("  Loading class from local repository");
++                if (resolve)
++                    resolveClass(clazz);
++                return (clazz);
+             }
+-    
+-            // (2) Search local repositories
++        } catch (ClassNotFoundException e) {
++            ;
++        }
++
++        // (3) Delegate to parent unconditionally
++        if (!delegateLoad) {
+             if (log.isDebugEnabled())
+-                log.debug("  Searching local repositories");
++                log.debug("  Delegating to parent classloader at end: " + parent);
++            ClassLoader loader = parent;
++            if (loader == null)
++                loader = system;
+             try {
+-                clazz = findClass(name);
++                clazz = loader.loadClass(name);
+                 if (clazz != null) {
+                     if (log.isDebugEnabled())
+-                        log.debug("  Loading class from local repository");
++                        log.debug("  Loading class from parent");
+                     if (resolve)
+                         resolveClass(clazz);
+                     return (clazz);
+@@ -1535,30 +1554,10 @@
+             } catch (ClassNotFoundException e) {
+                 ;
+             }
+-    
+-            // (3) Delegate to parent unconditionally
+-            if (!delegateLoad) {
+-                if (log.isDebugEnabled())
+-                    log.debug("  Delegating to parent classloader at end: " + parent);
+-                ClassLoader loader = parent;
+-                if (loader == null)
+-                    loader = system;
+-                try {
+-                    clazz = loader.loadClass(name);
+-                    if (clazz != null) {
+-                        if (log.isDebugEnabled())
+-                            log.debug("  Loading class from parent");
+-                        if (resolve)
+-                            resolveClass(clazz);
+-                        return (clazz);
+-                    }
+-                } catch (ClassNotFoundException e) {
+-                    ;
+-                }
+-            }
+-    
+-            throw new ClassNotFoundException(name);
+         }
++
++        throw new ClassNotFoundException(name);
++
+     }
+ 
+ 
+@@ -2544,7 +2543,7 @@
+         if (clazz != null)
+             return clazz;
+ 
+-        synchronized (name.intern()) {
++        synchronized (this) {
+             clazz = entry.loadedClass;
+             if (clazz != null)
+                 return clazz;




More information about the pkg-java-commits mailing list