Skip to content

Commit ea00ab9

Browse files
committed
Protect against NoSuchMethodError when deploying to old Tomcats
Fixes gh-19308
1 parent 0e6932d commit ea00ab9

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,13 @@ private void customizeRemoteIpValve(ConfigurableTomcatWebServerFactory factory)
186186
// The internal proxies default to a white list of "safe" internal IP
187187
// addresses
188188
valve.setInternalProxies(tomcatProperties.getInternalProxies());
189-
valve.setHostHeader(tomcatProperties.getHostHeader());
189+
try {
190+
valve.setHostHeader(tomcatProperties.getHostHeader());
191+
}
192+
catch (NoSuchMethodError ex) {
193+
// Avoid failure with war deployments to Tomcat 8.5 before 8.5.44 and
194+
// Tomcat 9 before 9.0.23
195+
}
190196
valve.setPortHeader(tomcatProperties.getPortHeader());
191197
valve.setProtocolHeaderHttpsValue(tomcatProperties.getProtocolHeaderHttpsValue());
192198
// ... so it's safe to add this valve by default.

0 commit comments

Comments
 (0)