From b725c6017701331d689ab9fd647b878b11e3536d Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Wed, 17 Jul 2019 15:36:58 +0100 Subject: [PATCH] Deprecate DeploymentInfo customization with reactive Undertow Fixes gh-17555 --- ...etManagementChildContextConfiguration.java | 3 +- .../UndertowWebServerFactoryCustomizer.java | 2 - ...rtowServletWebServerFactoryCustomizer.java | 45 +++++++++++++++++++ .../ConfigurableUndertowWebServerFactory.java | 5 +++ .../UndertowReactiveWebServerFactory.java | 7 +++ 5 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/UndertowServletWebServerFactoryCustomizer.java diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java index 67a1bc82e5..ff71f69c60 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java @@ -44,6 +44,7 @@ import org.springframework.boot.autoconfigure.web.embedded.TomcatWebServerFactor import org.springframework.boot.autoconfigure.web.embedded.UndertowWebServerFactoryCustomizer; import org.springframework.boot.autoconfigure.web.servlet.ServletWebServerFactoryCustomizer; import org.springframework.boot.autoconfigure.web.servlet.TomcatServletWebServerFactoryCustomizer; +import org.springframework.boot.autoconfigure.web.servlet.UndertowServletWebServerFactoryCustomizer; import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; @@ -113,7 +114,7 @@ class ServletManagementChildContextConfiguration { ServletManagementWebServerFactoryCustomizer(ListableBeanFactory beanFactory) { super(beanFactory, ServletWebServerFactoryCustomizer.class, TomcatServletWebServerFactoryCustomizer.class, TomcatWebServerFactoryCustomizer.class, JettyWebServerFactoryCustomizer.class, - UndertowWebServerFactoryCustomizer.class); + UndertowServletWebServerFactoryCustomizer.class, UndertowWebServerFactoryCustomizer.class); } @Override 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 03a53b8487..5cdc23269f 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 @@ -82,8 +82,6 @@ public class UndertowWebServerFactoryCustomizer .to((maxHttpPostSize) -> customizeMaxHttpPostSize(factory, maxHttpPostSize)); propertyMapper.from(properties::getConnectionTimeout) .to((connectionTimeout) -> customizeConnectionTimeout(factory, connectionTimeout)); - factory.addDeploymentInfoCustomizers( - (deploymentInfo) -> deploymentInfo.setEagerFilterInit(undertowProperties.isEagerFilterInit())); } private boolean isPositive(Number value) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/UndertowServletWebServerFactoryCustomizer.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/UndertowServletWebServerFactoryCustomizer.java new file mode 100644 index 0000000000..86362316f5 --- /dev/null +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/UndertowServletWebServerFactoryCustomizer.java @@ -0,0 +1,45 @@ +/* + * 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. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.springframework.boot.autoconfigure.web.servlet; + +import org.springframework.boot.autoconfigure.web.ServerProperties; +import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; + +/** + * {@link WebServerFactoryCustomizer} to apply {@link ServerProperties} to Undertow + * Servlet web servers. + * + * @author Andy Wilkinson + * @since 2.1.7 + */ +public class UndertowServletWebServerFactoryCustomizer + implements WebServerFactoryCustomizer { + + private final ServerProperties serverProperties; + + public UndertowServletWebServerFactoryCustomizer(ServerProperties serverProperties) { + this.serverProperties = serverProperties; + } + + @Override + public void customize(UndertowServletWebServerFactory factory) { + factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo + .setEagerFilterInit(this.serverProperties.getUndertow().isEagerFilterInit())); + } + +} diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/ConfigurableUndertowWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/ConfigurableUndertowWebServerFactory.java index 324bc41f02..fe88d881ac 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/ConfigurableUndertowWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/ConfigurableUndertowWebServerFactory.java @@ -44,7 +44,12 @@ public interface ConfigurableUndertowWebServerFactory extends ConfigurableWebSer * Add {@link UndertowDeploymentInfoCustomizer}s that should be used to customize the * Undertow {@link DeploymentInfo}. * @param customizers the customizers to add + * @deprecated since 2.1.7 in favor of + * {@link UndertowServletWebServerFactory#addDeploymentInfoCustomizers(UndertowDeploymentInfoCustomizer...)} + * as {@link UndertowReactiveWebServerFactory} does not create a + * {@link DeploymentInfo} */ + @Deprecated void addDeploymentInfoCustomizers(UndertowDeploymentInfoCustomizer... customizers); /** diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java index 272cc7812f..7ce1a90c38 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/UndertowReactiveWebServerFactory.java @@ -54,6 +54,7 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF private List builderCustomizers = new ArrayList<>(); + @Deprecated private List deploymentInfoCustomizers = new ArrayList<>(); private Integer bufferSize; @@ -203,7 +204,10 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF * Undertow {@link DeploymentInfo}. Calling this method will replace any existing * customizers. * @param customizers the customizers to set + * @deprecated since 2.1.7 as the factory does not create a {@link DeploymentInfo} + * making customization redundant */ + @Deprecated public void setDeploymentInfoCustomizers(Collection customizers) { Assert.notNull(customizers, "Customizers must not be null"); this.deploymentInfoCustomizers = new ArrayList<>(customizers); @@ -213,7 +217,10 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF * Returns a mutable collection of the {@link UndertowDeploymentInfoCustomizer}s that * will be applied to the Undertow {@link DeploymentInfo}. * @return the customizers that will be applied + * @deprecated since 2.1.7 as the factory does not create a {@link DeploymentInfo} + * making customization redundant */ + @Deprecated public Collection getDeploymentInfoCustomizers() { return this.deploymentInfoCustomizers; }