Skip to content

Commit ab2a257

Browse files
committed
Polish contribution
Closes gh-6571
1 parent 7efdb91 commit ab2a257

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -658,15 +658,15 @@ public static class Tomcat {
658658
private Charset uriEncoding;
659659

660660
/**
661-
* Maximum amount of connections accept and process.
662-
* <p>Once the limit has been reached,
663-
* the operating system may still accept connections based on the @link{acceptCount} setting.</p>
661+
* Maximum number of connections that the server will accept and process
662+
* at any given time. Once the limit has been reached, the operating system
663+
* may still accept connections based on the "acceptCount" property.
664664
*/
665665
private int maxConnections = 0;
666666

667667
/**
668-
* Maximum queue length for incoming connection requests when all possible request processing threads are in use.
669-
* Any requests received when the queue is full will be refused.
668+
* Maximum queue length for incoming connection requests when all possible
669+
* request processing threads are in use.
670670
*/
671671
private int acceptCount = 0;
672672

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

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.apache.catalina.Context;
3333
import org.apache.catalina.Valve;
3434
import org.apache.catalina.valves.RemoteIpValve;
35+
import org.apache.coyote.AbstractProtocol;
3536
import org.junit.Before;
3637
import org.junit.Test;
3738
import org.mockito.ArgumentCaptor;
@@ -324,22 +325,6 @@ public void testCustomizeTomcatMinSpareThreads() throws Exception {
324325
assertThat(this.properties.getTomcat().getMinSpareThreads()).isEqualTo(10);
325326
}
326327

327-
@Test
328-
public void testCustomizeTomcatAcceptCount() throws Exception {
329-
Map<String, String> map = new HashMap<String, String>();
330-
map.put("server.tomcat.accept-count", "10");
331-
bindProperties(map);
332-
assertThat(this.properties.getTomcat().getAcceptCount()).isEqualTo(10);
333-
}
334-
335-
@Test
336-
public void testCustomizeTomcatMaxConnections() throws Exception {
337-
Map<String, String> map = new HashMap<String, String>();
338-
map.put("server.tomcat.max-connections", "5");
339-
bindProperties(map);
340-
assertThat(this.properties.getTomcat().getMaxConnections()).isEqualTo(5);
341-
}
342-
343328
@Test
344329
public void customizeTomcatDisplayName() throws Exception {
345330
Map<String, String> map = new HashMap<String, String>();
@@ -451,6 +436,34 @@ public void customTomcatRemoteIpValve() throws Exception {
451436
assertThat(remoteIpValve.getInternalProxies()).isEqualTo("192.168.0.1");
452437
}
453438

439+
@Test
440+
public void customTomcatAcceptCount() {
441+
Map<String, String> map = new HashMap<String, String>();
442+
map.put("server.tomcat.accept-count", "10");
443+
bindProperties(map);
444+
445+
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
446+
this.properties.customize(container);
447+
TomcatEmbeddedServletContainer embeddedContainer =
448+
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
449+
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
450+
.getProtocolHandler()).getBacklog()).isEqualTo(10);
451+
}
452+
453+
@Test
454+
public void customTomcatMaxConnections() {
455+
Map<String, String> map = new HashMap<String, String>();
456+
map.put("server.tomcat.max-connections", "5");
457+
bindProperties(map);
458+
459+
TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory();
460+
this.properties.customize(container);
461+
TomcatEmbeddedServletContainer embeddedContainer =
462+
(TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer();
463+
assertThat(((AbstractProtocol) embeddedContainer.getTomcat().getConnector()
464+
.getProtocolHandler()).getMaxConnections()).isEqualTo(5);
465+
}
466+
454467
@Test
455468
public void defaultUseForwardHeadersUndertow() throws Exception {
456469
UndertowEmbeddedServletContainerFactory container = spy(

spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ content into your application; rather pick only the properties that you need.
193193
server.ssl.trust-store-password= # Password used to access the trust store.
194194
server.ssl.trust-store-provider= # Provider for the trust store.
195195
server.ssl.trust-store-type= # Type of the trust store.
196+
server.tomcat.accept-count= # Maximum queue length for incoming connection requests when all possible request processing threads are in use.
196197
server.tomcat.accesslog.directory=logs # Directory in which log files are created. Can be relative to the tomcat base dir or absolute.
197198
server.tomcat.accesslog.enabled=false # Enable access log.
198199
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.
208209
172\\.1[6-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
209210
172\\.2[0-9]{1}\\.\\d{1,3}\\.\\d{1,3}|\\
210211
172\\.3[0-1]{1}\\.\\d{1,3}\\.\\d{1,3} # regular expression matching trusted IP addresses.
212+
server.tomcat.max-connections= # Maximum number of connections that the server will accept and process at any given time.
211213
server.tomcat.max-threads=0 # Maximum amount of worker threads.
212214
server.tomcat.min-spare-threads=0 # Minimum amount of worker threads.
213215
server.tomcat.port-header=X-Forwarded-Port # Name of the HTTP header used to override the original port value.

0 commit comments

Comments
 (0)