Commit 9e7d9225 authored by Andy Wilkinson's avatar Andy Wilkinson

Allow processor cache to be configured to be unlimited

Closes gh-16415
parent ea80ca2f
......@@ -368,7 +368,8 @@ public class ServerProperties {
/**
* Maximum number of idle processors that will be retained in the cache and reused
* with a subsequent request.
* with a subsequent request. When set to -1 the cache will be unlimited with a
* theoretical maximum size equal to the maximum number of connections.
*/
private int processorCache = 200;
......
......@@ -110,7 +110,7 @@ public class TomcatWebServerFactoryCustomizer implements
.to((maxConnections) -> customizeMaxConnections(factory, maxConnections));
propertyMapper.from(tomcatProperties::getAcceptCount).when(this::isPositive)
.to((acceptCount) -> customizeAcceptCount(factory, acceptCount));
propertyMapper.from(tomcatProperties::getProcessorCache).when(this::isPositive)
propertyMapper.from(tomcatProperties::getProcessorCache)
.to((processorCache) -> customizeProcessorCache(factory, processorCache));
customizeStaticResources(factory);
customizeErrorReportValve(properties.getError(), factory);
......
......@@ -89,7 +89,17 @@ public class TomcatWebServerFactoryCustomizerTests {
@Test
public void customProcessorCache() {
bind("server.tomcat.processor-cache=100");
assertThat(this.serverProperties.getTomcat().getProcessorCache()).isEqualTo(100);
customizeAndRunServer((server) -> assertThat(((AbstractProtocol<?>) server
.getTomcat().getConnector().getProtocolHandler()).getProcessorCache())
.isEqualTo(100));
}
@Test
public void unlimitedProcessorCache() {
bind("server.tomcat.processor-cache=-1");
customizeAndRunServer((server) -> assertThat(((AbstractProtocol<?>) server
.getTomcat().getConnector().getProtocolHandler()).getProcessorCache())
.isEqualTo(-1));
}
@Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment