Skip to content

Commit 6df3de7

Browse files
committed
Merge branch 'main' into 4.0.x
2 parents 9d0061b + 9a1ca2f commit 6df3de7

File tree

3 files changed

+44
-2
lines changed

3 files changed

+44
-2
lines changed

spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfiguration.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
4040
import org.springframework.boot.autoconfigure.condition.SearchStrategy;
4141
import org.springframework.boot.autoconfigure.web.ServerProperties;
42-
import org.springframework.boot.context.properties.EnableConfigurationProperties;
4342
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
4443
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
4544
import org.springframework.boot.web.embedded.undertow.UndertowServletWebServerFactory;
@@ -67,7 +66,6 @@
6766
*/
6867
@ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false)
6968
@ConditionalOnWebApplication(type = Type.SERVLET)
70-
@EnableConfigurationProperties(ManagementServerProperties.class)
7169
class ServletManagementChildContextConfiguration {
7270

7371
@Bean

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/reactive/ReactiveManagementChildContextConfigurationTests.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.junit.jupiter.api.Test;
2020

2121
import org.springframework.boot.actuate.autoconfigure.web.reactive.ReactiveManagementChildContextConfiguration.AccessLogCustomizer;
22+
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
23+
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
2224

2325
import static org.assertj.core.api.Assertions.assertThat;
2426

@@ -46,4 +48,24 @@ void accessLogCustomizerWithNullPrefix() {
4648
assertThat(customizer.customizePrefix("existing")).isEqualTo("existing");
4749
}
4850

51+
@Test
52+
// gh-45857
53+
void failsWithoutManagementServerPropertiesBeanFromParent() {
54+
new ReactiveWebApplicationContextRunner().run((parent) -> {
55+
new ReactiveWebApplicationContextRunner().withParent(parent)
56+
.withUserConfiguration(ReactiveManagementChildContextConfiguration.class)
57+
.run((context) -> assertThat(context).hasFailed());
58+
});
59+
}
60+
61+
@Test
62+
// gh-45857
63+
void succeedsWithManagementServerPropertiesBeanFromParent() {
64+
new ReactiveWebApplicationContextRunner().withBean(ManagementServerProperties.class).run((parent) -> {
65+
new ReactiveWebApplicationContextRunner().withParent(parent)
66+
.withUserConfiguration(ReactiveManagementChildContextConfiguration.class)
67+
.run((context) -> assertThat(context).hasNotFailed());
68+
});
69+
}
70+
4971
}

spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/ServletManagementChildContextConfigurationTests.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
import org.junit.jupiter.api.Test;
2020

21+
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties;
2122
import org.springframework.boot.actuate.autoconfigure.web.servlet.ServletManagementChildContextConfiguration.AccessLogCustomizer;
23+
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
2224

2325
import static org.assertj.core.api.Assertions.assertThat;
2426

@@ -46,4 +48,24 @@ void accessLogCustomizerWithNullPrefix() {
4648
assertThat(customizer.customizePrefix("existing")).isEqualTo("existing");
4749
}
4850

51+
@Test
52+
// gh-45857
53+
void failsWithoutManagementServerPropertiesBeanFromParent() {
54+
new WebApplicationContextRunner().run((parent) -> {
55+
new WebApplicationContextRunner().withParent(parent)
56+
.withUserConfiguration(ServletManagementChildContextConfiguration.class)
57+
.run((context) -> assertThat(context).hasFailed());
58+
});
59+
}
60+
61+
@Test
62+
// gh-45857
63+
void succeedsWithManagementServerPropertiesBeanFromParent() {
64+
new WebApplicationContextRunner().withBean(ManagementServerProperties.class).run((parent) -> {
65+
new WebApplicationContextRunner().withParent(parent)
66+
.withUserConfiguration(ServletManagementChildContextConfiguration.class)
67+
.run((context) -> assertThat(context).hasNotFailed());
68+
});
69+
}
70+
4971
}

0 commit comments

Comments
 (0)