Merge branch '3.3.x' into 3.4.x

This commit is contained in:
Phillip Webb 2025-02-19 15:53:15 -08:00
commit c74397af1a
1 changed files with 10 additions and 7 deletions

View File

@ -240,7 +240,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
TomcatEmbeddedContext context = new TomcatEmbeddedContext(); TomcatEmbeddedContext context = new TomcatEmbeddedContext();
WebResourceRoot resourceRoot = (documentRoot != null) ? new LoaderHidingResourceRoot(context) WebResourceRoot resourceRoot = (documentRoot != null) ? new LoaderHidingResourceRoot(context)
: new StandardRoot(context); : new StandardRoot(context);
resourceRoot.setReadOnly(true); ignoringNoSuchMethodError(() -> resourceRoot.setReadOnly(true));
context.setResources(resourceRoot); context.setResources(resourceRoot);
context.setName(getContextPath()); context.setName(getContextPath());
context.setDisplayName(getDisplayName()); context.setDisplayName(getDisplayName());
@ -253,12 +253,7 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
context.setParentClassLoader(parentClassLoader); context.setParentClassLoader(parentClassLoader);
resetDefaultLocaleMapping(context); resetDefaultLocaleMapping(context);
addLocaleMappings(context); addLocaleMappings(context);
try { ignoringNoSuchMethodError(() -> context.setCreateUploadTargets(true));
context.setCreateUploadTargets(true);
}
catch (NoSuchMethodError ex) {
// Tomcat is < 8.5.39. Continue.
}
configureTldPatterns(context); configureTldPatterns(context);
WebappLoader loader = new WebappLoader(); WebappLoader loader = new WebappLoader();
loader.setLoaderInstance(new TomcatEmbeddedWebappClassLoader(parentClassLoader)); loader.setLoaderInstance(new TomcatEmbeddedWebappClassLoader(parentClassLoader));
@ -278,6 +273,14 @@ public class TomcatServletWebServerFactory extends AbstractServletWebServerFacto
postProcessContext(context); postProcessContext(context);
} }
private void ignoringNoSuchMethodError(Runnable method) {
try {
method.run();
}
catch (NoSuchMethodError ex) {
}
}
/** /**
* Override Tomcat's default locale mappings to align with other servers. See * Override Tomcat's default locale mappings to align with other servers. See
* {@code org.apache.catalina.util.CharsetMapperDefault.properties}. * {@code org.apache.catalina.util.CharsetMapperDefault.properties}.