diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
index 44e07102d3..e55a4a77ae 100644
--- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
+++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java
@@ -658,15 +658,15 @@ public class ServerProperties
private Charset uriEncoding;
/**
- * Maximum amount of connections accept and process.
- *
Once the limit has been reached,
- * the operating system may still accept connections based on the @link{acceptCount} setting.
+ * Maximum number of connections that the server will accept and process
+ * at any given time. Once the limit has been reached, the operating system
+ * may still accept connections based on the "acceptCount" property.
*/
private int maxConnections = 0;
/**
- * Maximum queue length for incoming connection requests when all possible request processing threads are in use.
- * Any requests received when the queue is full will be refused.
+ * Maximum queue length for incoming connection requests when all possible
+ * request processing threads are in use.
*/
private int acceptCount = 0;
diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
index 3de4bbddea..dd276071fc 100644
--- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
+++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java
@@ -32,6 +32,7 @@ import javax.servlet.SessionTrackingMode;
import org.apache.catalina.Context;
import org.apache.catalina.Valve;
import org.apache.catalina.valves.RemoteIpValve;
+import org.apache.coyote.AbstractProtocol;
import org.junit.Before;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
@@ -324,22 +325,6 @@ public class ServerPropertiesTests {
assertThat(this.properties.getTomcat().getMinSpareThreads()).isEqualTo(10);
}
- @Test
- public void testCustomizeTomcatAcceptCount() throws Exception {
- Map map = new HashMap();
- map.put("server.tomcat.accept-count", "10");
- bindProperties(map);
- assertThat(this.properties.getTomcat().getAcceptCount()).isEqualTo(10);
- }
-
- @Test
- public void testCustomizeTomcatMaxConnections() throws Exception {
- Map map = new HashMap();
- map.put("server.tomcat.max-connections", "5");
- bindProperties(map);
- assertThat(this.properties.getTomcat().getMaxConnections()).isEqualTo(5);
- }
-
@Test
public void customizeTomcatDisplayName() throws Exception {
Map map = new HashMap();
@@ -451,6 +436,34 @@ public class ServerPropertiesTests {
assertThat(remoteIpValve.getInternalProxies()).isEqualTo("192.168.0.1");
}
+ @Test
+ public void customTomcatAcceptCount() {
+ Map map = new HashMap();
+ map.put("server.tomcat.accept-count", "10");
+ bindProperties(map);
+
+ TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
+ this.properties.customize(container);
+ TomcatEmbeddedServletContainer embeddedContainer =
+ (TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
+ assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
+ .getProtocolHandler()).getBacklog()).isEqualTo(10);
+ }
+
+ @Test
+ public void customTomcatMaxConnections() {
+ Map map = new HashMap();
+ map.put("server.tomcat.max-connections", "5");
+ bindProperties(map);
+
+ TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
+ this.properties.customize(container);
+ TomcatEmbeddedServletContainer embeddedContainer =
+ (TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
+ assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
+ .getProtocolHandler()).getMaxConnections()).isEqualTo(5);
+ }
+
@Test
public void defaultUseForwardHeadersUndertow() throws Exception {
UndertowEmbeddedServletContainerFactory container = spy(
diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
index 4750e0db17..d3a3e4c8df 100644
--- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
+++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
@@ -193,6 +193,7 @@ content into your application; rather pick only the properties that you need.
server.ssl.trust-store-password= # Password used to access the trust store.
server.ssl.trust-store-provider= # Provider for the trust store.
server.ssl.trust-store-type= # Type of the trust store.
+ server.tomcat.accept-count= # Maximum queue length for incoming connection requests when all possible request processing threads are in use.
server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be relative to the tomcat base dir or absolute.
server.tomcat.accesslog.enabled=false # Enable access log.
server.tomcat.accesslog.pattern=common # Format pattern for access logs.
@@ -208,6 +209,7 @@ content into your application; rather pick only the properties that you need.
172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
+ server.tomcat.max-connections= # Maximum number of connections that the server will accept and process at any given time.
server.tomcat.max-threads=0 # Maximum amount of worker threads.
server.tomcat.min-spare-threads=0 # Minimum amount of worker threads.
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.