Skip to content

Commit 0abe38d

Browse files
committed
Merge branch '2.2.x' into 2.3.x
Closes gh-23676
2 parents a9a32f3 + 7fc345f commit 0abe38d

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryConfiguration.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
3333
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
3434
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
35+
import org.springframework.boot.autoconfigure.web.ServerProperties;
3536
import org.springframework.boot.web.embedded.jetty.JettyServerCustomizer;
3637
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
3738
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
@@ -121,6 +122,12 @@ UndertowServletWebServerFactory undertowServletWebServerFactory(
121122
return factory;
122123
}
123124

125+
@Bean
126+
UndertowServletWebServerFactoryCustomizer undertowServletWebServerFactoryCustomizer(
127+
ServerProperties serverProperties) {
128+
return new UndertowServletWebServerFactoryCustomizer(serverProperties);
129+
}
130+
124131
}
125132

126133
}

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/servlet/UndertowServletWebServerFactoryCustomizer.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,8 +38,7 @@ public UndertowServletWebServerFactoryCustomizer(ServerProperties serverProperti
3838

3939
@Override
4040
public void customize(UndertowServletWebServerFactory factory) {
41-
factory.addDeploymentInfoCustomizers((deploymentInfo) -> deploymentInfo
42-
.setEagerFilterInit(this.serverProperties.getUndertow().isEagerFilterInit()));
41+
factory.setEagerInitFilters(this.serverProperties.getUndertow().isEagerFilterInit());
4342
}
4443

4544
}

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/servlet/ServletWebServerFactoryAutoConfigurationTests.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,17 @@ void undertowBuilderCustomizerBeanIsAddedToFactory() {
243243
});
244244
}
245245

246+
@Test
247+
void undertowServletWebServerFactoryCustomizerIsAutoConfigured() {
248+
WebApplicationContextRunner runner = new WebApplicationContextRunner(
249+
AnnotationConfigServletWebServerApplicationContext::new)
250+
.withClassLoader(new FilteredClassLoader(Tomcat.class, HttpServer.class, Server.class))
251+
.withConfiguration(AutoConfigurations.of(ServletWebServerFactoryAutoConfiguration.class))
252+
.withUserConfiguration(UndertowBuilderCustomizerConfiguration.class)
253+
.withPropertyValues("server.port:0");
254+
runner.run((context) -> assertThat(context).hasSingleBean(UndertowServletWebServerFactoryCustomizer.class));
255+
}
256+
246257
@Test
247258
void tomcatConnectorCustomizerBeanIsAddedToFactory() {
248259
WebApplicationContextRunner runner = new WebApplicationContextRunner(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright 2012-2020 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.boot.autoconfigure.web.servlet;
18+
19+
import org.junit.jupiter.api.Test;
20+
21+
import org.springframework.boot.autoconfigure.web.ServerProperties;
22+
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
23+
24+
import static org.assertj.core.api.Assertions.assertThat;
25+
26+
/**
27+
* Tests for {@link UndertowServletWebServerFactoryCustomizer}
28+
*
29+
* @author Andy Wilkinson
30+
*/
31+
class UndertowServletWebServerFactoryCustomizerTests {
32+
33+
@Test
34+
void eagerFilterInitCanBeDisabled() {
35+
UndertowServletWebServerFactory factory = new UndertowServletWebServerFactory(0);
36+
assertThat(factory.isEagerInitFilters()).isTrue();
37+
ServerProperties serverProperties = new ServerProperties();
38+
serverProperties.getUndertow().setEagerFilterInit(false);
39+
new UndertowServletWebServerFactoryCustomizer(serverProperties).customize(factory);
40+
assertThat(factory.isEagerInitFilters()).isFalse();
41+
}
42+
43+
}

0 commit comments

Comments
 (0)