This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 8.5.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 8a7384de384345b2372a73b677e35bb0f817920b Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Jan 16 11:10:13 2020 +0000 https://bz.apache.org/bugzilla/show_bug.cgi?id=64021 SCI ordering Ensure that container provided SCIs are always loaded before application provided SCIs. Where both container and application provide the same SCI, the application takes priority. SCI definitions from JARS unpacked into WEB-INF/classes are now handled consistently and will always be found irrespective of whether the web application defines a JAR ordering or not. --- .../catalina/startup/WebappServiceLoader.java | 29 ++++++++++++++++------ webapps/docs/changelog.xml | 11 ++++++++ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/java/org/apache/catalina/startup/WebappServiceLoader.java b/java/org/apache/catalina/startup/WebappServiceLoader.java index a47a8f9..d6b7623 100644 --- a/java/org/apache/catalina/startup/WebappServiceLoader.java +++ b/java/org/apache/catalina/startup/WebappServiceLoader.java @@ -34,6 +34,7 @@ import java.util.regex.Pattern; import javax.servlet.ServletContext; import org.apache.catalina.Context; +import org.apache.catalina.WebResource; import org.apache.tomcat.util.scan.JarFactory; /** @@ -58,6 +59,7 @@ import org.apache.tomcat.util.scan.JarFactory; * @see java.util.ServiceLoader */ public class WebappServiceLoader<T> { + private static final String CLASSES = "/WEB-INF/classes/"; private static final String LIB = "/WEB-INF/lib/"; private static final String SERVICES = "META-INF/services/"; @@ -99,10 +101,23 @@ public class WebappServiceLoader<T> { // if the ServletContext has ORDERED_LIBS, then use that to specify the // set of JARs from WEB-INF/lib that should be used for loading services @SuppressWarnings("unchecked") - List<String> orderedLibs = - (List<String>) servletContext.getAttribute(ServletContext.ORDERED_LIBS); - if (orderedLibs != null) { - // handle ordered libs directly, ... + List<String> orderedLibs = (List<String>) servletContext.getAttribute(ServletContext.ORDERED_LIBS); + + // Handle application SCIs directly... + if (orderedLibs == null) { + // No ordered libs, so use every service definition we can find + WebResource[] resources = context.getResources().getClassLoaderResources("/" + configFile); + for (WebResource resource : resources) { + if (resource.isFile()) { + parseConfigFile(applicationServicesFound, resource.getURL()); + } + } + } else { + // Ordered libs so only use services defined in those libs and any + // in WEB-INF/classes + URL unpacked = servletContext.getResource(CLASSES + configFile); + parseConfigFile(applicationServicesFound, unpacked); + for (String lib : orderedLibs) { URL jarUrl = servletContext.getResource(LIB + lib); if (jarUrl == null) { @@ -123,11 +138,11 @@ public class WebappServiceLoader<T> { // no provider file found, this is OK } } - - // and the parent ClassLoader for all others - loader = context.getParentClassLoader(); } + // and use the parent ClassLoader for all other SCIs + loader = context.getParentClassLoader(); + Enumeration<URL> resources; if (loader == null) { resources = ClassLoader.getSystemResources(configFile); diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml index 641bdfd..f8e24c7 100644 --- a/webapps/docs/changelog.xml +++ b/webapps/docs/changelog.xml @@ -88,6 +88,17 @@ (michaelo) </fix> <fix> + <bug>64021</bug>: Ensure that container provided SCIs are always loaded + before application provided SCIs. Note that where both the container and + the application provide the same SCI, it is the application provided SCI + that will be used. (markt) + </fix> + <fix> + SCI definitions from JARs unpacked into <code>WEB-INF/classes</code> are + now handled consistently and will always be found irrespective of + whether the web application defines a JAR ordering or not. (markt) + </fix> + <fix> <bug>64023</bug>: Skip null-valued session attributes when deserializing sessions. (schultz) </fix> --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org