Skip to content

Commit 076ddc8

Browse files
committed
Polish "Add server.netty.max-keep-alive-requests"
See gh-28875
1 parent 0e94b2c commit 076ddc8

File tree

4 files changed

+19
-26
lines changed

4 files changed

+19
-26
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -68,7 +68,6 @@
6868
* @author Victor Mandujano
6969
* @author Chris Bono
7070
* @author Parviz Rozikov
71-
* @author Leo Li
7271
* @since 1.0.0
7372
*/
7473
@ConfigurationProperties(prefix = "server", ignoreUnknownFields = true)
@@ -1341,6 +1340,12 @@ public static class Netty {
13411340
*/
13421341
private DataSize maxInitialLineLength = DataSize.ofKilobytes(4);
13431342

1343+
/**
1344+
* Maximum number of requests that can be made per connection. By default, a
1345+
* connection serves unlimited number of requests.
1346+
*/
1347+
private Integer maxKeepAliveRequests;
1348+
13441349
/**
13451350
* Whether to validate headers when decoding requests.
13461351
*/
@@ -1352,11 +1357,6 @@ public static class Netty {
13521357
*/
13531358
private Duration idleTimeout;
13541359

1355-
/**
1356-
* Maximum number of requests that can be made per connection.
1357-
*/
1358-
private int maxKeepAliveRequests = -1;
1359-
13601360
public Duration getConnectionTimeout() {
13611361
return this.connectionTimeout;
13621362
}
@@ -1397,6 +1397,14 @@ public void setMaxInitialLineLength(DataSize maxInitialLineLength) {
13971397
this.maxInitialLineLength = maxInitialLineLength;
13981398
}
13991399

1400+
public Integer getMaxKeepAliveRequests() {
1401+
return this.maxKeepAliveRequests;
1402+
}
1403+
1404+
public void setMaxKeepAliveRequests(Integer maxKeepAliveRequests) {
1405+
this.maxKeepAliveRequests = maxKeepAliveRequests;
1406+
}
1407+
14001408
public boolean isValidateHeaders() {
14011409
return this.validateHeaders;
14021410
}
@@ -1413,14 +1421,6 @@ public void setIdleTimeout(Duration idleTimeout) {
14131421
this.idleTimeout = idleTimeout;
14141422
}
14151423

1416-
public int getMaxKeepAliveRequests() {
1417-
return this.maxKeepAliveRequests;
1418-
}
1419-
1420-
public void setMaxKeepAliveRequests(int maxKeepAliveRequests) {
1421-
this.maxKeepAliveRequests = maxKeepAliveRequests;
1422-
}
1423-
14241424
}
14251425

14261426
/**

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -34,7 +34,6 @@
3434
* @author Brian Clozel
3535
* @author Chentao Qu
3636
* @author Artsiom Yudovin
37-
* @author Leo Li
3837
* @since 2.1.0
3938
*/
4039
public class NettyWebServerFactoryCustomizer
@@ -63,7 +62,7 @@ public void customize(NettyReactiveWebServerFactory factory) {
6362
.to((connectionTimeout) -> customizeConnectionTimeout(factory, connectionTimeout));
6463
propertyMapper.from(nettyProperties::getIdleTimeout).whenNonNull()
6564
.to((idleTimeout) -> customizeIdleTimeout(factory, idleTimeout));
66-
propertyMapper.from(nettyProperties::getMaxKeepAliveRequests).whenNonNull()
65+
propertyMapper.from(nettyProperties::getMaxKeepAliveRequests)
6766
.to((maxKeepAliveRequests) -> customizeMaxKeepAliveRequests(factory, maxKeepAliveRequests));
6867
customizeRequestDecoder(factory, propertyMapper);
6968
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.
@@ -84,7 +84,6 @@
8484
* @author Rafiullah Hamedy
8585
* @author Chris Bono
8686
* @author Parviz Rozikov
87-
* @author Leo Li
8887
*/
8988
class ServerPropertiesTests {
9089

@@ -346,11 +345,6 @@ void testCustomizeNettyMaxKeepAliveRequests() {
346345
assertThat(this.properties.getNetty().getMaxKeepAliveRequests()).isEqualTo(100);
347346
}
348347

349-
@Test
350-
void testCustomizeNettyMaxKeepAliveRequestsDefault() {
351-
assertThat(this.properties.getNetty().getMaxKeepAliveRequests()).isEqualTo(-1);
352-
}
353-
354348
@Test
355349
void tomcatAcceptCountMatchesProtocolDefault() throws Exception {
356350
assertThat(this.properties.getTomcat().getAcceptCount()).isEqualTo(getDefaultProtocol().getAcceptCount());

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/NettyWebServerFactoryCustomizerTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2022 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.

0 commit comments

Comments
 (0)