Fix connector used to configure connection timeout

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

Closes gh-7425
pull/7462/head
Grigory Fadeev 8 years ago committed by Phillip Webb
parent a3b79be6b3
commit 1ea829e003

@ -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 {
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");

Loading…
Cancel
Save