Do not assume HTTP protocol when customizing processor cache
Closes gh-16413
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
.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);
|
||||
|
||||
Reference in New Issue
Block a user