This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit f6e1482d4c78f1fb459384dd87ef3dc4cad81008 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 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/java/org/apache/catalina/core/StandardContext.java b/java/org/apache/catalina/core/StandardContext.java index 5f2e8b1..abb276c 100644 --- a/java/org/apache/catalina/core/StandardContext.java +++ b/java/org/apache/catalina/core/StandardContext.java @@ -4842,7 +4842,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 455e657..d681baa 100644 --- a/java/org/apache/catalina/loader/WebappLoader.java +++ b/java/org/apache/catalina/loader/WebappLoader.java @@ -69,8 +69,8 @@ public class WebappLoader extends LifecycleMBeanBase // ----------------------------------------------------------- Constructors /** - * 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() { this(null); @@ -82,7 +82,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; @@ -507,6 +512,8 @@ public class WebappLoader extends LifecycleMBeanBase if (parentClassLoader == null) { parentClassLoader = context.getParentClassLoader(); + } else { + context.setParentClassLoader(parentClassLoader); } Class<?>[] argTypes = { ClassLoader.class }; Object[] args = { parentClassLoader }; --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org