diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java index d4e2d4ba876..5fa0645b0a3 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ServerProperties.java @@ -834,7 +834,7 @@ public class ServerProperties if (maxHttpHeaderSize > 0) { customizeMaxHttpHeaderSize(factory, maxHttpHeaderSize); } - if (this.maxHttpPostSize > 0) { + if (this.maxHttpPostSize != 0) { customizeMaxHttpPostSize(factory, this.maxHttpPostSize); } if (this.accesslog.enabled) { diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java index e6819d95c1e..aaf1641b7e2 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/ServerPropertiesTests.java @@ -574,6 +574,25 @@ public class ServerPropertiesTests { } } + @Test + public void customTomcatDisableMaxHttpPostSize() { + Map map = new HashMap(); + map.put("server.tomcat.max-http-post-size", "-1"); + bindProperties(map); + TomcatEmbeddedServletContainerFactory container = new TomcatEmbeddedServletContainerFactory(0); + this.properties.customize(container); + TomcatEmbeddedServletContainer embeddedContainer = + (TomcatEmbeddedServletContainer) container.getEmbeddedServletContainer(); + embeddedContainer.start(); + try { + assertThat(embeddedContainer.getTomcat().getConnector().getMaxPostSize()) + .isEqualTo(-1); + } + finally { + embeddedContainer.stop(); + } + } + @Test @Deprecated public void customTomcatMaxHttpPostSizeWithDeprecatedProperty() {