Allow processor cache to be configured to be unlimited
Closes gh-16415
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user