Commit 1ea829e0 authored by Grigory Fadeev's avatar Grigory Fadeev Committed by Phillip Webb

Fix connector used to configure connection timeout

Fix Tomcat customization so that the main connection is configured with
any timeout.

Closes gh-7425
parent a3b79be6
...@@ -809,14 +809,20 @@ public class ServerProperties ...@@ -809,14 +809,20 @@ public class ServerProperties
} }
private void customizeConnectionTimeout( private void customizeConnectionTimeout(
TomcatEmbeddedServletContainerFactory factory, int connectionTimeout) { TomcatEmbeddedServletContainerFactory factory,
for (Connector connector : factory.getAdditionalTomcatConnectors()) { final int connectionTimeout) {
if (connector.getProtocolHandler() instanceof AbstractProtocol) { factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
AbstractProtocol<?> handler = (AbstractProtocol<?>) connector
.getProtocolHandler(); @Override
handler.setConnectionTimeout(connectionTimeout); public void customize(Connector connector) {
ProtocolHandler handler = connector.getProtocolHandler();
if (handler instanceof AbstractProtocol) {
AbstractProtocol<?> protocol = (AbstractProtocol<?>) handler;
protocol.setConnectionTimeout(connectionTimeout);
} }
} }
});
} }
private void customizeRemoteIpValve(ServerProperties properties, private void customizeRemoteIpValve(ServerProperties properties,
......
...@@ -111,6 +111,14 @@ public class ServerPropertiesTests { ...@@ -111,6 +111,14 @@ public class ServerPropertiesTests {
assertThat(this.properties.getServerHeader()).isEqualTo("Custom Server"); assertThat(this.properties.getServerHeader()).isEqualTo("Custom Server");
} }
@Test
public void testConnectionTimeout() throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("server.connection-timeout", "60000");
bindProperties(map);
assertThat(this.properties.getConnectionTimeout()).isEqualTo(60000);
}
@Test @Test
public void testServletPathAsMapping() throws Exception { public void testServletPathAsMapping() throws Exception {
RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server"); RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment