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(
TomcatEmbeddedServletContainerFactory factory, int connectionTimeout) {
for (Connector connector : factory.getAdditionalTomcatConnectors()) {
if (connector.getProtocolHandler() instanceof AbstractProtocol) {
AbstractProtocol<?> handler = (AbstractProtocol<?>) connector
.getProtocolHandler();
handler.setConnectionTimeout(connectionTimeout);
TomcatEmbeddedServletContainerFactory factory,
final int connectionTimeout) {
factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
@Override
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,

@ -111,6 +111,14 @@ public class ServerPropertiesTests {
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
public void testServletPathAsMapping() throws Exception {
RelaxedDataBinder binder = new RelaxedDataBinder(this.properties, "server");

Loading…
Cancel
Save