Browse Source

Do not assume HTTP protocol when customizing processor cache

Closes gh-16413
pull/16419/head
Andy Wilkinson 7 years ago
parent
commit
ea80ca2ffc
  1. 9
      spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java
  2. 11
      spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java

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

@ -133,9 +133,12 @@ public class TomcatWebServerFactoryCustomizer implements @@ -133,9 +133,12 @@ public class TomcatWebServerFactoryCustomizer implements
private void customizeProcessorCache(ConfigurableTomcatWebServerFactory factory,
int processorCache) {
factory.addConnectorCustomizers((
connector) -> ((AbstractHttp11Protocol<?>) connector.getProtocolHandler())
.setProcessorCache(processorCache));
factory.addConnectorCustomizers((connector) -> {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
((AbstractProtocol<?>) handler).setProcessorCache(processorCache);
}
});
}
private void customizeMaxConnections(ConfigurableTomcatWebServerFactory factory,

11
spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java

@ -36,6 +36,7 @@ import org.springframework.boot.context.properties.bind.Binder; @@ -36,6 +36,7 @@ import org.springframework.boot.context.properties.bind.Binder;
import org.springframework.boot.context.properties.source.ConfigurationPropertySources;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.embedded.tomcat.TomcatWebServer;
import org.springframework.boot.web.server.WebServer;
import org.springframework.mock.env.MockEnvironment;
import org.springframework.test.context.support.TestPropertySourceUtils;
import org.springframework.util.unit.DataSize;
@ -421,6 +422,16 @@ public class TomcatWebServerFactoryCustomizerTests { @@ -421,6 +422,16 @@ public class TomcatWebServerFactoryCustomizerTests {
.getIpv6Canonical()).isTrue();
}
@Test
public void ajpConnectorCanBeCustomized() {
TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory(0);
factory.setProtocol("AJP/1.3");
this.customizer.customize(factory);
WebServer server = factory.getWebServer();
server.start();
server.stop();
}
private void bind(String... inlinedProperties) {
TestPropertySourceUtils.addInlinedPropertiesToEnvironment(this.environment,
inlinedProperties);

Loading…
Cancel
Save