Author: markt
Date: Sat Nov  4 13:21:07 2006
New Revision: 471263

URL: http://svn.apache.org/viewvc?view=rev&rev=471263
Log:
Port fix bug 37458. Remove the possibility of some NPE and IAE issues.
Note for Remy - you had some ideas to improve this patch.

Modified:
    tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java

Modified: 
tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java
URL: 
http://svn.apache.org/viewvc/tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java?view=diff&rev=471263&r1=471262&r2=471263
==============================================================================
--- tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java 
(original)
+++ tomcat/tc6.0.x/trunk/java/org/apache/catalina/loader/WebappClassLoader.java 
Sat Nov  4 13:21:07 2006
@@ -1758,63 +1758,58 @@
         if (clazz != null)
             return clazz;
 
-        synchronized (this) {
+        synchronized (entry) {
             if (entry.binaryContent == null && entry.loadedClass == null)
                 throw new ClassNotFoundException(name);
-        }
 
-        // Looking up the package
-        String packageName = null;
-        int pos = name.lastIndexOf('.');
-        if (pos != -1)
-            packageName = name.substring(0, pos);
-
-        Package pkg = null;
-
-        if (packageName != null) {
-
-            pkg = getPackage(packageName);
-
-            // Define the package (if null)
-            if (pkg == null) {
-                if (entry.manifest == null) {
-                    definePackage(packageName, null, null, null, null, null,
-                                  null, null);
-                } else {
-                    definePackage(packageName, entry.manifest, entry.codeBase);
+            // Looking up the package
+            String packageName = null;
+            int pos = name.lastIndexOf('.');
+            if (pos != -1)
+                packageName = name.substring(0, pos);
+        
+            Package pkg = null;
+        
+            if (packageName != null) {
+                synchronized (this) {
+                    pkg = getPackage(packageName);
+            
+                    // Define the package (if null)
+                    if (pkg == null) {
+                        if (entry.manifest == null) {
+                            definePackage(packageName, null, null, null, null,
+                                    null, null, null);
+                        } else {
+                            definePackage(packageName, entry.manifest,
+                                    entry.codeBase);
+                        }
+                    }
                 }
             }
+    
+            if (securityManager != null) {
 
-        }
-
-        // Create the code source object
-        CodeSource codeSource =
-            new CodeSource(entry.codeBase, entry.certificates);
-
-        if (securityManager != null) {
-
-            // Checking sealing
-            if (pkg != null) {
-                boolean sealCheck = true;
-                if (pkg.isSealed()) {
-                    sealCheck = pkg.isSealed(entry.codeBase);
-                } else {
-                    sealCheck = (entry.manifest == null)
-                        || !isPackageSealed(packageName, entry.manifest);
+                // Checking sealing
+                if (pkg != null) {
+                    boolean sealCheck = true;
+                    if (pkg.isSealed()) {
+                        sealCheck = pkg.isSealed(entry.codeBase);
+                    } else {
+                        sealCheck = (entry.manifest == null)
+                            || !isPackageSealed(packageName, entry.manifest);
+                    }
+                    if (!sealCheck)
+                        throw new SecurityException
+                            ("Sealing violation loading " + name + " : Package 
"
+                             + packageName + " is sealed.");
                 }
-                if (!sealCheck)
-                    throw new SecurityException
-                        ("Sealing violation loading " + name + " : Package "
-                         + packageName + " is sealed.");
+    
             }
 
-        }
-
-        synchronized (this) {
             if (entry.loadedClass == null) {
                 clazz = defineClass(name, entry.binaryContent, 0,
                         entry.binaryContent.length, 
-                        codeSource);
+                        new CodeSource(entry.codeBase, entry.certificates));
                 entry.loadedClass = clazz;
                 entry.binaryContent = null;
                 entry.source = null;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to