From dbce3731a4b8e4c824baf55529d98437a73e918d Mon Sep 17 00:00:00 2001 From: ayudovin Date: Thu, 31 Jan 2019 16:48:55 +0300 Subject: [PATCH 1/2] Set NO_REQUEST_TIMEOUT as a server option not a socket option See gh-15822 --- .../UndertowWebServerFactoryCustomizer.java | 3 ++- .../UndertowWebServerFactoryCustomizerTests.java | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java index 312bcfb82ee..d6b2899872b 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java @@ -37,6 +37,7 @@ import org.springframework.util.unit.DataSize; * @author Yulin Qin * @author Stephane Nicoll * @author Phillip Webb + * @author Arstiom Yudovin * @since 2.0.0 */ public class UndertowWebServerFactoryCustomizer implements @@ -106,7 +107,7 @@ public class UndertowWebServerFactoryCustomizer implements private void customizeConnectionTimeout(ConfigurableUndertowWebServerFactory factory, Duration connectionTimeout) { - factory.addBuilderCustomizers((builder) -> builder.setSocketOption( + factory.addBuilderCustomizers((builder) -> builder.setServerOption( UndertowOptions.NO_REQUEST_TIMEOUT, (int) connectionTimeout.toMillis())); } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java index 401370dde0c..0fa420fad99 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java @@ -47,6 +47,7 @@ import static org.mockito.Mockito.verify; * * @author Brian Clozel * @author Phillip Webb + * @author Artsiom Yudovin */ public class UndertowWebServerFactoryCustomizerTests { @@ -143,6 +144,18 @@ public class UndertowWebServerFactoryCustomizerTests { assertThat(map.contains(UndertowOptions.MAX_HEADER_SIZE)).isFalse(); } + @Test + public void customConnectionTimeout() { + bind("server.connection-timeout=100"); + Builder builder = Undertow.builder(); + ConfigurableUndertowWebServerFactory factory = mockFactory(builder); + this.customizer.customize(factory); + OptionMap map = ((OptionMap.Builder) ReflectionTestUtils.getField(builder, + "serverOptions")).getMap(); + assertThat(map.contains(UndertowOptions.NO_REQUEST_TIMEOUT)).isTrue(); + assertThat(map.get(UndertowOptions.NO_REQUEST_TIMEOUT)).isEqualTo(100); + } + private ConfigurableUndertowWebServerFactory mockFactory(Builder builder) { ConfigurableUndertowWebServerFactory factory = mock( ConfigurableUndertowWebServerFactory.class); From 295a660e35764f1d5b7c1fcb4c836eb26da9bbff Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Mon, 11 Feb 2019 17:11:20 +0000 Subject: [PATCH 2/2] Polish "Set NO_REQUEST_TIMEOUT as a server option not a socket option" See gh-15822 --- .../web/embedded/UndertowWebServerFactoryCustomizer.java | 2 +- .../web/embedded/UndertowWebServerFactoryCustomizerTests.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java index d6b2899872b..4cf49c219da 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizer.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java index 0fa420fad99..0e50897fa4d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/embedded/UndertowWebServerFactoryCustomizerTests.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2018 the original author or authors. + * Copyright 2012-2019 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.