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 2020/02/26 18:54:22 UTC

[tomcat] branch 7.0.x updated: BZ 64153. Ensure Context.getParentClassLoader() is consistent

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

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


The following commit(s) were added to refs/heads/7.0.x by this push:
     new 32c44a0  BZ 64153. Ensure Context.getParentClassLoader() is consistent
32c44a0 is described below

commit 32c44a0d4d3a55fbd1d4effa62884624b92a7829
Author: Mark Thomas <ma...@apache.org>
AuthorDate: Wed Feb 26 17:43:41 2020 +0000

    BZ 64153. Ensure Context.getParentClassLoader() is consistent
    
    Deprecate the setting of the parent class loader via the Loader and if
    it is set via the loader, keep it in sync with the Context.
    Fixes https://bz.apache.org/bugzilla/show_bug.cgi?id=64153
---
 java/org/apache/catalina/core/StandardContext.java |  2 +-
 java/org/apache/catalina/loader/WebappLoader.java  | 11 +++++++++--
 webapps/docs/changelog.xml                         |  4 ++++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/catalina/core/StandardContext.java b/java/org/apache/catalina/core/StandardContext.java
index d96deab..fce298c 100644
--- a/java/org/apache/catalina/core/StandardContext.java
+++ b/java/org/apache/catalina/core/StandardContext.java
@@ -5455,7 +5455,7 @@ public class StandardContext extends ContainerBase
         }
 
         if (getLoader() == null) {
-            WebappLoader webappLoader = new WebappLoader(getParentClassLoader());
+            WebappLoader webappLoader = new WebappLoader();
             webappLoader.setDelegate(getDelegate());
             setLoader(webappLoader);
         }
diff --git a/java/org/apache/catalina/loader/WebappLoader.java b/java/org/apache/catalina/loader/WebappLoader.java
index 6c87beb..d2d2751 100644
--- a/java/org/apache/catalina/loader/WebappLoader.java
+++ b/java/org/apache/catalina/loader/WebappLoader.java
@@ -85,8 +85,8 @@ public class WebappLoader extends LifecycleMBeanBase
 
 
     /**
-     * Construct a new WebappLoader with no defined parent class loader
-     * (so that the actual parent will be the system class loader).
+     * Construct a new WebappLoader. The parent class loader will be defined by
+     * {@link Context#getParentClassLoader()}.
      */
     public WebappLoader() {
 
@@ -100,7 +100,12 @@ public class WebappLoader extends LifecycleMBeanBase
      * to be defined as the parent of the ClassLoader we ultimately create.
      *
      * @param parent The parent class loader
+     *
+     * @deprecated Use {@link Context#setParentClassLoader(ClassLoader)} to
+     *             specify the required class loader. This method will be
+     *             removed in Tomcat 10 onwards.
      */
+    @Deprecated
     public WebappLoader(ClassLoader parent) {
         super();
         this.parentClassLoader = parent;
@@ -746,6 +751,8 @@ public class WebappLoader extends LifecycleMBeanBase
 
         if (parentClassLoader == null) {
             parentClassLoader = container.getParentClassLoader();
+        } else {
+            container.setParentClassLoader(parentClassLoader);
         }
         Class<?>[] argTypes = { ClassLoader.class };
         Object[] args = { parentClassLoader };
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 66b009b..79de737 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -73,6 +73,10 @@
         and the GET response uses chunking. (markt)
       </fix>
       <fix>
+        <bug>64153</bug>: Ensure that the parent for the web application class
+        loader is set consistently. 
+      </fix>
+      <fix>
         <bug>64166</bug>: Ensure that the names returned by
         <code>HttpServletResponse.getHeaderNames()</code> are unique. (markt)
       </fix>


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