Merge branch '2.1.x'
Closes gh-17562
This commit is contained in:
@@ -45,6 +45,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;
|
||||
@@ -115,7 +116,7 @@ class ServletManagementChildContextConfiguration {
|
||||
ServletManagementWebServerFactoryCustomizer(ListableBeanFactory beanFactory) {
|
||||
super(beanFactory, ServletWebServerFactoryCustomizer.class, TomcatServletWebServerFactoryCustomizer.class,
|
||||
TomcatWebServerFactoryCustomizer.class, JettyWebServerFactoryCustomizer.class,
|
||||
UndertowWebServerFactoryCustomizer.class);
|
||||
UndertowServletWebServerFactoryCustomizer.class, UndertowWebServerFactoryCustomizer.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -92,7 +92,6 @@ public class UndertowWebServerFactoryCustomizer
|
||||
map.from(properties::getIoThreads).to(factory::setIoThreads);
|
||||
map.from(properties::getWorkerThreads).to(factory::setWorkerThreads);
|
||||
map.from(properties::getDirectBuffers).to(factory::setUseDirectBuffers);
|
||||
map.from(properties::isEagerFilterInit).to((x) -> setEagerFilterInit(factory, x));
|
||||
map.from(properties::getMaxHttpPostSize).as(DataSize::toBytes).when(this::isPositive)
|
||||
.to(options.server(UndertowOptions.MAX_ENTITY_SIZE));
|
||||
map.from(properties::getMaxParameters).to(options.server(UndertowOptions.MAX_PARAMETERS));
|
||||
@@ -106,10 +105,6 @@ public class UndertowWebServerFactoryCustomizer
|
||||
map.from(properties.getOptions()::getSocket).to(options.forEach(options::socket));
|
||||
}
|
||||
|
||||
private void setEagerFilterInit(ConfigurableUndertowWebServerFactory factory, Boolean eagerFilterInit) {
|
||||
factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo.setEagerFilterInit(eagerFilterInit));
|
||||
}
|
||||
|
||||
private boolean isPositive(Number value) {
|
||||
return value.longValue() > 0;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ import org.springframework.boot.web.embedded.tomcat.TomcatContextCustomizer;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatProtocolHandlerCustomizer;
|
||||
import org.springframework.boot.web.embedded.tomcat.TomcatReactiveWebServerFactory;
|
||||
import org.springframework.boot.web.embedded.undertow.UndertowBuilderCustomizer;
|
||||
import org.springframework.boot.web.embedded.undertow.UndertowDeploymentInfoCustomizer;
|
||||
import org.springframework.boot.web.embedded.undertow.UndertowReactiveWebServerFactory;
|
||||
import org.springframework.boot.web.reactive.server.ReactiveWebServerFactory;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -128,11 +127,8 @@ abstract class ReactiveWebServerFactoryConfiguration {
|
||||
|
||||
@Bean
|
||||
UndertowReactiveWebServerFactory undertowReactiveWebServerFactory(
|
||||
ObjectProvider<UndertowDeploymentInfoCustomizer> deploymentInfoCustomizers,
|
||||
ObjectProvider<UndertowBuilderCustomizer> builderCustomizers) {
|
||||
UndertowReactiveWebServerFactory factory = new UndertowReactiveWebServerFactory();
|
||||
factory.getDeploymentInfoCustomizers()
|
||||
.addAll(deploymentInfoCustomizers.orderedStream().collect(Collectors.toList()));
|
||||
factory.getBuilderCustomizers().addAll(builderCustomizers.orderedStream().collect(Collectors.toList()));
|
||||
return factory;
|
||||
}
|
||||
|
||||
@@ -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<UndertowServletWebServerFactory> {
|
||||
|
||||
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()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -244,19 +244,6 @@ class ReactiveWebServerFactoryAutoConfigurationTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void undertowDeploymentInfoCustomizerBeanIsAddedToFactory() {
|
||||
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new)
|
||||
.withConfiguration(AutoConfigurations.of(ReactiveWebServerFactoryAutoConfiguration.class))
|
||||
.withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class))
|
||||
.withUserConfiguration(UndertowDeploymentInfoCustomizerConfiguration.class,
|
||||
HttpHandlerConfiguration.class)
|
||||
.run((context) -> {
|
||||
UndertowReactiveWebServerFactory factory = context.getBean(UndertowReactiveWebServerFactory.class);
|
||||
assertThat(factory.getDeploymentInfoCustomizers()).hasSize(1);
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void undertowBuilderCustomizerBeanIsAddedToFactory() {
|
||||
new ReactiveWebApplicationContextRunner(AnnotationConfigReactiveWebApplicationContext::new)
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.boot.web.embedded.undertow;
|
||||
import java.io.File;
|
||||
|
||||
import io.undertow.Undertow.Builder;
|
||||
import io.undertow.servlet.api.DeploymentInfo;
|
||||
|
||||
import org.springframework.boot.web.server.ConfigurableWebServerFactory;
|
||||
|
||||
@@ -40,13 +39,6 @@ public interface ConfigurableUndertowWebServerFactory extends ConfigurableWebSer
|
||||
*/
|
||||
void addBuilderCustomizers(UndertowBuilderCustomizer... customizers);
|
||||
|
||||
/**
|
||||
* Add {@link UndertowDeploymentInfoCustomizer}s that should be used to customize the
|
||||
* Undertow {@link DeploymentInfo}.
|
||||
* @param customizers the customizers to add
|
||||
*/
|
||||
void addDeploymentInfoCustomizers(UndertowDeploymentInfoCustomizer... customizers);
|
||||
|
||||
/**
|
||||
* Set the buffer size.
|
||||
* @param bufferSize buffer size
|
||||
|
||||
@@ -33,7 +33,6 @@ import io.undertow.UndertowOptions;
|
||||
import io.undertow.server.HttpHandler;
|
||||
import io.undertow.server.handlers.accesslog.AccessLogHandler;
|
||||
import io.undertow.server.handlers.accesslog.DefaultAccessLogReceiver;
|
||||
import io.undertow.servlet.api.DeploymentInfo;
|
||||
import org.xnio.OptionMap;
|
||||
import org.xnio.Options;
|
||||
import org.xnio.Xnio;
|
||||
@@ -56,6 +55,7 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
|
||||
|
||||
private Set<UndertowBuilderCustomizer> builderCustomizers = new LinkedHashSet<>();
|
||||
|
||||
@Deprecated
|
||||
private List<UndertowDeploymentInfoCustomizer> deploymentInfoCustomizers = new ArrayList<>();
|
||||
|
||||
private Integer bufferSize;
|
||||
@@ -200,32 +200,6 @@ public class UndertowReactiveWebServerFactory extends AbstractReactiveWebServerF
|
||||
return getAddress().getHostAddress();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set {@link UndertowDeploymentInfoCustomizer}s that should be applied to the
|
||||
* Undertow {@link DeploymentInfo}. Calling this method will replace any existing
|
||||
* customizers.
|
||||
* @param customizers the customizers to set
|
||||
*/
|
||||
public void setDeploymentInfoCustomizers(Collection<? extends UndertowDeploymentInfoCustomizer> customizers) {
|
||||
Assert.notNull(customizers, "Customizers must not be null");
|
||||
this.deploymentInfoCustomizers = new ArrayList<>(customizers);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
public Collection<UndertowDeploymentInfoCustomizer> getDeploymentInfoCustomizers() {
|
||||
return this.deploymentInfoCustomizers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDeploymentInfoCustomizers(UndertowDeploymentInfoCustomizer... customizers) {
|
||||
Assert.notNull(customizers, "UndertowDeploymentInfoCustomizers must not be null");
|
||||
this.deploymentInfoCustomizers.addAll(Arrays.asList(customizers));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAccessLogDirectory(File accessLogDirectory) {
|
||||
this.accessLogDirectory = accessLogDirectory;
|
||||
|
||||
@@ -196,7 +196,11 @@ public class UndertowServletWebServerFactory extends AbstractServletWebServerFac
|
||||
return this.deploymentInfoCustomizers;
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* Add {@link UndertowDeploymentInfoCustomizer}s that should be used to customize the
|
||||
* Undertow {@link DeploymentInfo}.
|
||||
* @param customizers the customizers to add
|
||||
*/
|
||||
public void addDeploymentInfoCustomizers(UndertowDeploymentInfoCustomizer... customizers) {
|
||||
Assert.notNull(customizers, "UndertowDeploymentInfoCustomizers must not be null");
|
||||
this.deploymentInfoCustomizers.addAll(Arrays.asList(customizers));
|
||||
|
||||
Reference in New Issue
Block a user