You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2021/07/30 07:29:56 UTC

[tomcat] branch 9.0.x updated: Revert clean-up. definePackage always needs to be called.

This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
     new 25d289b  Revert clean-up. definePackage always needs to be called.
25d289b is described below

commit 25d289ba53e5c514be854e78f777fc420c3b9d2f
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Fri Jul 30 08:20:28 2021 +0100

    Revert clean-up. definePackage always needs to be called.
---
 .../catalina/loader/WebappClassLoaderBase.java     | 68 ++++++++++++----------
 webapps/docs/changelog.xml                         | 10 +++-
 2 files changed, 46 insertions(+), 32 deletions(-)

diff --git a/java/org/apache/catalina/loader/WebappClassLoaderBase.java b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
index 0d2bb7c..288d26e 100644
--- a/java/org/apache/catalina/loader/WebappClassLoaderBase.java
+++ b/java/org/apache/catalina/loader/WebappClassLoaderBase.java
@@ -2430,40 +2430,46 @@ public abstract class WebappClassLoaderBase extends URLClassLoader
                 }
             }
 
-            if (securityManager != null) {
-                // Looking up the package
-                int pos = name.lastIndexOf('.');
-                if (pos != -1) {
-                    String packageName = name.substring(0, pos);
-                    Package pkg = getPackage(packageName);
-
-                    // Define the package (if null)
-                    if (pkg == null) {
-                        try {
-                            if (manifest == null) {
-                                definePackage(packageName, null, null, null, null, null, null, null);
-                            } else {
-                                definePackage(packageName, manifest, codeBase);
-                            }
-                        } catch (IllegalArgumentException e) {
-                            // Ignore: normal error due to dual definition of package
-                        }
-                        pkg = getPackage(packageName);
-                    }
+            // Looking up the package
+            String packageName = null;
+            int pos = name.lastIndexOf('.');
+            if (pos != -1) {
+                packageName = name.substring(0, pos);
+            }
+
+            Package pkg = null;
 
-                    // Checking sealing
-                    if (pkg != null) {
-                        boolean sealCheck = true;
-                        if (pkg.isSealed()) {
-                            sealCheck = pkg.isSealed(codeBase);
+            if (packageName != null) {
+                pkg = getPackage(packageName);
+
+                // Define the package (if null)
+                if (pkg == null) {
+                    try {
+                        if (manifest == null) {
+                            definePackage(packageName, null, null, null, null, null, null, null);
                         } else {
-                            sealCheck = (manifest == null) || !isPackageSealed(packageName, manifest);
-                        }
-                        if (!sealCheck) {
-                            throw new SecurityException
-                                ("Sealing violation loading " + name + " : Package "
-                                 + packageName + " is sealed.");
+                            definePackage(packageName, manifest, codeBase);
                         }
+                    } catch (IllegalArgumentException e) {
+                        // Ignore: normal error due to dual definition of package
+                    }
+                    pkg = getPackage(packageName);
+                }
+            }
+
+            if (securityManager != null) {
+                // Checking sealing
+                if (pkg != null) {
+                    boolean sealCheck = true;
+                    if (pkg.isSealed()) {
+                        sealCheck = pkg.isSealed(codeBase);
+                    } else {
+                        sealCheck = (manifest == null) || !isPackageSealed(packageName, manifest);
+                    }
+                    if (!sealCheck) {
+                        throw new SecurityException
+                            ("Sealing violation loading " + name + " : Package "
+                             + packageName + " is sealed.");
                     }
                 }
             }
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 3a3e3cd..b6a86b6 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,8 +105,16 @@
   issues do not "pop up" wrt. others).
 -->
 <section name="Tomcat 9.0.52 (remm)" rtext="in development">
+  <subsection name="Catalina">
+    <changelog>
+      <scode>
+        Correct an error in some code clean-up that mean that web application
+        classes were not configured with the correct package. (markt)
+      </scode>
+    </changelog>
+  </subsection>
 </section>
-<section name="Tomcat 9.0.51 (remm)" rtext="in progress">
+<section name="Tomcat 9.0.51 (remm)" rtext="not released">
   <subsection name="Catalina">
     <changelog>
       <fix>

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