Skip to content

Commit 9e7d922

Browse files
committed
Allow processor cache to be configured to be unlimited
Closes gh-16415
1 parent ea80ca2 commit 9e7d922

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ public static class Tomcat {
368368

369369
/**
370370
* Maximum number of idle processors that will be retained in the cache and reused
371-
* with a subsequent request.
371+
* with a subsequent request. When set to -1 the cache will be unlimited with a
372+
* theoretical maximum size equal to the maximum number of connections.
372373
*/
373374
private int processorCache = 200;
374375

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public void customize(ConfigurableTomcatWebServerFactory factory) {
110110
.to((maxConnections) -> customizeMaxConnections(factory, maxConnections));
111111
propertyMapper.from(tomcatProperties::getAcceptCount).when(this::isPositive)
112112
.to((acceptCount) -> customizeAcceptCount(factory, acceptCount));
113-
propertyMapper.from(tomcatProperties::getProcessorCache).when(this::isPositive)
113+
propertyMapper.from(tomcatProperties::getProcessorCache)
114114
.to((processorCache) -> customizeProcessorCache(factory, processorCache));
115115
customizeStaticResources(factory);
116116
customizeErrorReportValve(properties.getError(), factory);

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,17 @@ public void customAcceptCount() {
8989
@Test
9090
public void customProcessorCache() {
9191
bind("server.tomcat.processor-cache=100");
92-
assertThat(this.serverProperties.getTomcat().getProcessorCache()).isEqualTo(100);
92+
customizeAndRunServer((server) -> assertThat(((AbstractProtocol<?>) server
93+
.getTomcat().getConnector().getProtocolHandler()).getProcessorCache())
94+
.isEqualTo(100));
95+
}
96+
97+
@Test
98+
public void unlimitedProcessorCache() {
99+
bind("server.tomcat.processor-cache=-1");
100+
customizeAndRunServer((server) -> assertThat(((AbstractProtocol<?>) server
101+
.getTomcat().getConnector().getProtocolHandler()).getProcessorCache())
102+
.isEqualTo(-1));
93103
}
94104

95105
@Test

0 commit comments

Comments
 (0)