diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index c531c8bf1a..42aff713ec 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -372,18 +372,15 @@ public class ServerProperties { private int processorCache = 200; /** - * The number of milliseconds this Connector will wait for another HTTP request - * before closing the connection. The default value is to use the value that has - * been set for the connectionTimeout attribute. Use a value of -1 to indicate no - * (i.e. infinite) timeout. + * Time to wait for another HTTP request before the connection is closed. When not + * set the connectionTimeout is used. When set to -1 there will be no timeout. */ private Duration keepAliveTimeout; /** - * The maximum number of HTTP requests which can be pipelined until the connection - * is closed by the server./ Setting this attribute to 1 will disable HTTP/1.0 - * keep-alive as well as HTTP/1.1 keep-alive and pipelining. Setting this to -1 - * will allow an unlimited amount of pipelined or keep-alive HTTP requests. + * Maximum number of HTTP requests that can be pipelined before the connection is + * closed. When set to 0 or 1, keep-alive and pipelining are disabled. When set to + * -1, an unlimited number of pipelined or keep-alive requests is allowed. */ private int maxKeepAliveRequests = 100; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java index 87ba4bd8bd..05ecf41df5 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java @@ -233,6 +233,12 @@ class ServerPropertiesTests { @Test void customizeMaxKeepAliveRequests() { + bind("server.tomcat.max-keep-alive-requests", "200"); + assertThat(this.properties.getTomcat().getMaxKeepAliveRequests()).isEqualTo(200); + } + + @Test + void customizeMaxKeepAliveRequestsWithInfinite() { bind("server.tomcat.max-keep-alive-requests", "-1"); assertThat(this.properties.getTomcat().getMaxKeepAliveRequests()).isEqualTo(-1); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java index 7256b81584..6a3742a172 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java @@ -99,7 +99,7 @@ class TomcatWebServerFactoryCustomizerTests { } @Test - void customizeKeepAliveTimeout() { + void customKeepAliveTimeout() { bind("server.tomcat.keep-alive-timeout=30ms"); customizeAndRunServer((server) -> assertThat( ((AbstractProtocol) server.getTomcat().getConnector().getProtocolHandler()).getKeepAliveTimeout()) @@ -107,7 +107,7 @@ class TomcatWebServerFactoryCustomizerTests { } @Test - void customizeMaxKeepAliveRequests() { + void customMaxKeepAliveRequests() { bind("server.tomcat.max-keep-alive-requests=-1"); customizeAndRunServer((server) -> assertThat( ((AbstractHttp11Protocol) server.getTomcat().getConnector().getProtocolHandler())