diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index 7e63016ac6..86916226fd 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -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; diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java index 632a285016..2583bae330 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizer.java @@ -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); diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java index f99fe9f80a..23ce2f0450 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/TomcatWebServerFactoryCustomizerTests.java @@ -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