Upgrade to Tomcat 10.1.36

Closes gh-44339
This commit is contained in:
Andy Wilkinson 2025-02-19 15:35:33 +00:00 committed by Phillip Webb
parent 489fc83c53
commit eba12f4ebf
4 changed files with 13 additions and 9 deletions

View File

@ -21,6 +21,6 @@ nativeBuildToolsVersion=0.10.5
snakeYamlVersion=2.4 snakeYamlVersion=2.4
springFrameworkVersion=6.2.3 springFrameworkVersion=6.2.3
springFramework60xVersion=6.0.23 springFramework60xVersion=6.0.23
tomcatVersion=10.1.34 tomcatVersion=10.1.36
kotlin.stdlib.default.dependency=false kotlin.stdlib.default.dependency=false

View File

@ -2544,10 +2544,6 @@ bom {
versionRange "[11.0.0-M1,)" versionRange "[11.0.0-M1,)"
because "it exceeds our Jakarte EE 10 baseline" because "it exceeds our Jakarte EE 10 baseline"
} }
prohibit {
versionRange "[10.1.35,10.1.36]"
because "https://bz.apache.org/bugzilla/show_bug.cgi?id=69576 and related problems in 10.1.36"
}
group("org.apache.tomcat") { group("org.apache.tomcat") {
modules = [ modules = [
"tomcat-annotations-api", "tomcat-annotations-api",

View File

@ -36,6 +36,7 @@ import org.apache.catalina.connector.Connector;
import org.apache.catalina.core.AprLifecycleListener; import org.apache.catalina.core.AprLifecycleListener;
import org.apache.catalina.loader.WebappLoader; import org.apache.catalina.loader.WebappLoader;
import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.webresources.StandardRoot;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.apache.coyote.AbstractProtocol; import org.apache.coyote.AbstractProtocol;
@ -165,6 +166,9 @@ public class TomcatReactiveWebServerFactory extends AbstractReactiveWebServerFac
protected void prepareContext(Host host, TomcatHttpHandlerAdapter servlet) { protected void prepareContext(Host host, TomcatHttpHandlerAdapter servlet) {
File docBase = createTempDir("tomcat-docbase"); File docBase = createTempDir("tomcat-docbase");
TomcatEmbeddedContext context = new TomcatEmbeddedContext(); TomcatEmbeddedContext context = new TomcatEmbeddedContext();
StandardRoot resourcesRoot = new StandardRoot();
resourcesRoot.setReadOnly(true);
context.setResources(resourcesRoot);
context.setPath(""); context.setPath("");
context.setDocBase(docBase.getAbsolutePath()); context.setDocBase(docBase.getAbsolutePath());
context.addLifecycleListener(new Tomcat.FixContextListener()); context.addLifecycleListener(new Tomcat.FixContextListener());

View File

@ -238,9 +238,10 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
protected void prepareContext(Host host, ServletContextInitializer[] initializers) { protected void prepareContext(Host host, ServletContextInitializer[] initializers) {
File documentRoot = getValidDocumentRoot(); File documentRoot = getValidDocumentRoot();
TomcatEmbeddedContext context = new TomcatEmbeddedContext(); TomcatEmbeddedContext context = new TomcatEmbeddedContext();
if (documentRoot != null) { WebResourceRoot resourceRoot = (documentRoot != null) ? new LoaderHidingResourceRoot(context)
context.setResources(new LoaderHidingResourceRoot(context)); : new StandardRoot(context);
} resourceRoot.setReadOnly(true);
context.setResources(resourceRoot);
context.setName(getContextPath()); context.setName(getContextPath());
context.setDisplayName(getDisplayName()); context.setDisplayName(getDisplayName());
context.setPath(getContextPath()); context.setPath(getContextPath());
@ -814,7 +815,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
@Override @Override
public void lifecycleEvent(LifecycleEvent event) { public void lifecycleEvent(LifecycleEvent event) {
if (event.getType().equals(Lifecycle.CONFIGURE_START_EVENT)) { if (event.getType().equals(Lifecycle.BEFORE_INIT_EVENT)) {
addResourceJars(getUrlsOfJarsWithMetaInfResources()); addResourceJars(getUrlsOfJarsWithMetaInfResources());
} }
} }
@ -834,6 +835,9 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
addResourceSet(url.toString()); addResourceSet(url.toString());
} }
} }
for (WebResourceSet resources : this.context.getResources().getJarResources()) {
resources.setReadOnly(true);
}
} }
private void addResourceSet(String resource) { private void addResourceSet(String resource) {