Merge branch '2.1.x'

Closes gh-17562
This commit is contained in:
Andy Wilkinson
2019-07-18 07:22:24 +01:00
8 changed files with 53 additions and 59 deletions

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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()));
}
}

View File

@@ -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)