Skip to content

Commit a83d963

Browse files
committed
Merge branch '2.1.x'
2 parents ead9b51 + 6200a31 commit a83d963

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

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

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2018 the original author or authors.
2+
* Copyright 2012-2019 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -16,6 +16,10 @@
1616

1717
package org.springframework.boot.autoconfigure.web.embedded;
1818

19+
import java.time.Duration;
20+
21+
import io.netty.channel.ChannelOption;
22+
1923
import org.springframework.boot.autoconfigure.web.ServerProperties;
2024
import org.springframework.boot.cloud.CloudPlatform;
2125
import org.springframework.boot.context.properties.PropertyMapper;
@@ -31,6 +35,7 @@
3135
*
3236
* @author Brian Clozel
3337
* @author Chentao Qu
38+
* @author Artsiom Yudovin
3439
* @since 2.1.0
3540
*/
3641
public class NettyWebServerFactoryCustomizer
@@ -60,6 +65,10 @@ public void customize(NettyReactiveWebServerFactory factory) {
6065
.asInt(DataSize::toBytes)
6166
.to((maxHttpRequestHeaderSize) -> customizeMaxHttpHeaderSize(factory,
6267
maxHttpRequestHeaderSize));
68+
propertyMapper.from(this.serverProperties::getConnectionTimeout).whenNonNull()
69+
.asInt(Duration::toMillis)
70+
.to((duration) -> customizeConnectionTimeOut(factory, duration));
71+
6372
}
6473

6574
private boolean getOrDeduceUseForwardHeaders(ServerProperties serverProperties,
@@ -78,4 +87,11 @@ private void customizeMaxHttpHeaderSize(NettyReactiveWebServerFactory factory,
7887
.maxHeaderSize(maxHttpHeaderSize)));
7988
}
8089

90+
private void customizeConnectionTimeOut(NettyReactiveWebServerFactory factory,
91+
int duration) {
92+
factory.addServerCustomizers((NettyServerCustomizer) (httpServer) -> httpServer
93+
.tcpConfiguration((tcpServer) -> tcpServer
94+
.selectorOption(ChannelOption.CONNECT_TIMEOUT_MILLIS, duration)));
95+
}
96+
8197
}

0 commit comments

Comments
 (0)