Polish contribution

Closes gh-6571
This commit is contained in:
Stephane Nicoll
2016-10-10 11:28:54 +02:00
parent 7efdb91641
commit ab2a2579c8
3 changed files with 36 additions and 21 deletions

View File

@@ -658,15 +658,15 @@ public class ServerProperties
private Charset uriEncoding;
/**
* Maximum amount of connections accept and process.
* <p>Once the limit has been reached,
* the operating system may still accept connections based on the @link{acceptCount} setting.</p>
* 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;

View File

@@ -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<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.accept-count", "10");
bindProperties(map);
assertThat(this.properties.getTomcat().getAcceptCount()).isEqualTo(10);
}
@Test
public void testCustomizeTomcatMaxConnections() throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("server.tomcat.max-connections", "5");
bindProperties(map);
assertThat(this.properties.getTomcat().getMaxConnections()).isEqualTo(5);
}
@Test
public void customizeTomcatDisplayName() throws Exception {
Map<String, String> map = new HashMap<String, String>();
@@ -451,6 +436,34 @@ public class ServerPropertiesTests {
assertThat(remoteIpValve.getInternalProxies()).isEqualTo("192.168.0.1");
}
@Test
public void customTomcatAcceptCount() {
Map<String, String> map = new HashMap<String, String>();
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<String, String> map = new HashMap<String, String>();
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(