From 4ce7a14b258b340d6b30f5509206f28560ba08c1 Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Tue, 18 Feb 2025 12:55:55 +0000 Subject: [PATCH] Move WebServer-specific properties out of ManagementServerProperties Issue: 44324 --- .../server/ManagementServerProperties.java | 65 ------------------- .../jetty/JettyAccessLogCustomizer.java | 5 +- .../JettyManagementServerProperties.java | 53 +++++++++++++++ ...veManagementChildContextConfiguration.java | 5 +- ...etManagementChildContextConfiguration.java | 5 +- .../tomcat/TomcatAccessLogCustomizer.java | 5 +- .../TomcatManagementServerProperties.java | 53 +++++++++++++++ ...veManagementChildContextConfiguration.java | 5 +- ...etManagementChildContextConfiguration.java | 5 +- .../undertow/UndertowAccessLogCustomizer.java | 6 +- .../UndertowManagementServerProperties.java | 53 +++++++++++++++ ...veManagementChildContextConfiguration.java | 5 +- ...etManagementChildContextConfiguration.java | 5 +- .../ManagementServerPropertiesTests.java | 8 --- .../JettyManagementServerPropertiesTests.java | 36 ++++++++++ ...TomcatManagementServerPropertiesTests.java | 36 ++++++++++ ...dertowManagementServerPropertiesTests.java | 36 ++++++++++ 17 files changed, 286 insertions(+), 100 deletions(-) create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerProperties.java create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerProperties.java create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerProperties.java create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerPropertiesTests.java create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerPropertiesTests.java create mode 100644 spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerPropertiesTests.java diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java index 527b5f1bbe..89709259f3 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerProperties.java @@ -58,12 +58,6 @@ public class ManagementServerProperties { @NestedConfigurationProperty private Ssl ssl; - private final Jetty jetty = new Jetty(); - - private final Tomcat tomcat = new Tomcat(); - - private final Undertow undertow = new Undertow(); - /** * Returns the management port or {@code null} if the * {@link ServerProperties#getPort() server port} should be used. @@ -108,18 +102,6 @@ public class ManagementServerProperties { this.ssl = ssl; } - public Jetty getJetty() { - return this.jetty; - } - - public Tomcat getTomcat() { - return this.tomcat; - } - - public Undertow getUndertow() { - return this.undertow; - } - private String cleanBasePath(String basePath) { String candidate = null; if (StringUtils.hasLength(basePath)) { @@ -136,51 +118,4 @@ public class ManagementServerProperties { return candidate; } - public static class Jetty { - - private final Accesslog accesslog = new Accesslog(); - - public Accesslog getAccesslog() { - return this.accesslog; - } - - } - - public static class Tomcat { - - private final Accesslog accesslog = new Accesslog(); - - public Accesslog getAccesslog() { - return this.accesslog; - } - - } - - public static class Undertow { - - private final Accesslog accesslog = new Accesslog(); - - public Accesslog getAccesslog() { - return this.accesslog; - } - - } - - public static class Accesslog { - - /** - * Management log file name prefix. - */ - private String prefix = "management_"; - - public String getPrefix() { - return this.prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - } - } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyAccessLogCustomizer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyAccessLogCustomizer.java index 2799a3ed01..41198032e9 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyAccessLogCustomizer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyAccessLogCustomizer.java @@ -24,7 +24,6 @@ import org.eclipse.jetty.server.RequestLogWriter; import org.eclipse.jetty.server.Server; import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.server.jetty.ConfigurableJettyWebServerFactory; import org.springframework.util.StringUtils; @@ -37,8 +36,8 @@ import org.springframework.util.StringUtils; class JettyAccessLogCustomizer extends AccessLogCustomizer implements WebServerFactoryCustomizer { - JettyAccessLogCustomizer(ManagementServerProperties properties) { - super(properties.getJetty().getAccesslog().getPrefix()); + JettyAccessLogCustomizer(JettyManagementServerProperties properties) { + super(properties.getAccesslog().getPrefix()); } @Override diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerProperties.java new file mode 100644 index 0000000000..cebb409a63 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerProperties.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012-2025 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.actuate.autoconfigure.web.server.jetty; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties for a Jetty-based management server. + * + * @author Moritz Halbritter + * @since 4.0.0 + */ +@ConfigurationProperties("management.server.jetty") +public class JettyManagementServerProperties { + + private final Accesslog accesslog = new Accesslog(); + + public Accesslog getAccesslog() { + return this.accesslog; + } + + public static class Accesslog { + + /** + * Management log file name prefix. + */ + private String prefix = "management_"; + + public String getPrefix() { + return this.prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyReactiveManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyReactiveManagementChildContextConfiguration.java index 6886f0a08e..e3328eea98 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyReactiveManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyReactiveManagementChildContextConfiguration.java @@ -20,7 +20,6 @@ import org.eclipse.jetty.server.Server; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; @@ -36,12 +35,12 @@ import org.springframework.context.annotation.Bean; */ @ConditionalOnClass(Server.class) @ConditionalOnWebApplication(type = Type.REACTIVE) -@EnableConfigurationProperties(ManagementServerProperties.class) +@EnableConfigurationProperties(JettyManagementServerProperties.class) @ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) class JettyReactiveManagementChildContextConfiguration { @Bean - JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(ManagementServerProperties properties) { + JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(JettyManagementServerProperties properties) { return new JettyAccessLogCustomizer(properties); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyServletManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyServletManagementChildContextConfiguration.java index ab8a3adc1d..acb66c9be2 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyServletManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyServletManagementChildContextConfiguration.java @@ -20,7 +20,6 @@ import org.eclipse.jetty.server.Server; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; @@ -36,12 +35,12 @@ import org.springframework.context.annotation.Bean; */ @ConditionalOnClass(Server.class) @ConditionalOnWebApplication(type = Type.SERVLET) -@EnableConfigurationProperties(ManagementServerProperties.class) +@EnableConfigurationProperties(JettyManagementServerProperties.class) @ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) class JettyServletManagementChildContextConfiguration { @Bean - JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(ManagementServerProperties properties) { + JettyAccessLogCustomizer jettyManagementAccessLogCustomizer(JettyManagementServerProperties properties) { return new JettyAccessLogCustomizer(properties); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatAccessLogCustomizer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatAccessLogCustomizer.java index 5662a8ced1..53cbc37cc1 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatAccessLogCustomizer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatAccessLogCustomizer.java @@ -23,7 +23,6 @@ import org.apache.catalina.Valve; import org.apache.catalina.valves.AccessLogValve; import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.web.server.tomcat.ConfigurableTomcatWebServerFactory; /** @@ -36,9 +35,9 @@ class TomcatAccessLogCustomizer ex private final Function> engineValvesExtractor; - TomcatAccessLogCustomizer(ManagementServerProperties properties, + TomcatAccessLogCustomizer(TomcatManagementServerProperties properties, Function> engineValvesExtractor) { - super(properties.getTomcat().getAccesslog().getPrefix()); + super(properties.getAccesslog().getPrefix()); this.engineValvesExtractor = engineValvesExtractor; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerProperties.java new file mode 100644 index 0000000000..c6417fbc88 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerProperties.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012-2025 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.actuate.autoconfigure.web.server.tomcat; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties for a Tomcat-based management server. + * + * @author Moritz Halbritter + * @since 4.0.0 + */ +@ConfigurationProperties("management.server.tomcat") +public class TomcatManagementServerProperties { + + private final Accesslog accesslog = new Accesslog(); + + public Accesslog getAccesslog() { + return this.accesslog; + } + + public static class Accesslog { + + /** + * Management log file name prefix. + */ + private String prefix = "management_"; + + public String getPrefix() { + return this.prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatReactiveManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatReactiveManagementChildContextConfiguration.java index e7d2b7567b..d3cdf6a008 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatReactiveManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatReactiveManagementChildContextConfiguration.java @@ -20,7 +20,6 @@ import org.apache.catalina.startup.Tomcat; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; @@ -37,13 +36,13 @@ import org.springframework.context.annotation.Bean; */ @ConditionalOnClass(Tomcat.class) @ConditionalOnWebApplication(type = Type.REACTIVE) -@EnableConfigurationProperties(ManagementServerProperties.class) +@EnableConfigurationProperties(TomcatManagementServerProperties.class) @ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) class TomcatReactiveManagementChildContextConfiguration { @Bean TomcatAccessLogCustomizer tomcatManagementAccessLogCustomizer( - ManagementServerProperties properties) { + TomcatManagementServerProperties properties) { return new TomcatAccessLogCustomizer<>(properties, TomcatReactiveWebServerFactory::getEngineValves); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatServletManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatServletManagementChildContextConfiguration.java index fe52bacf62..0ec64115d5 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatServletManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatServletManagementChildContextConfiguration.java @@ -20,7 +20,6 @@ import org.apache.catalina.startup.Tomcat; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; @@ -37,13 +36,13 @@ import org.springframework.context.annotation.Bean; */ @ConditionalOnClass(Tomcat.class) @ConditionalOnWebApplication(type = Type.SERVLET) -@EnableConfigurationProperties(ManagementServerProperties.class) +@EnableConfigurationProperties(TomcatManagementServerProperties.class) @ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) class TomcatServletManagementChildContextConfiguration { @Bean TomcatAccessLogCustomizer tomcatManagementAccessLogCustomizer( - ManagementServerProperties properties) { + TomcatManagementServerProperties properties) { return new TomcatAccessLogCustomizer<>(properties, TomcatServletWebServerFactory::getEngineValves); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowAccessLogCustomizer.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowAccessLogCustomizer.java index 0f9e24be7a..9ac7c53ac0 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowAccessLogCustomizer.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowAccessLogCustomizer.java @@ -19,7 +19,6 @@ package org.springframework.boot.actuate.autoconfigure.web.server.undertow; import java.util.function.Function; import org.springframework.boot.actuate.autoconfigure.web.server.AccessLogCustomizer; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.web.server.undertow.ConfigurableUndertowWebServerFactory; /** @@ -32,8 +31,9 @@ class UndertowAccessLogCustomizer accessLogPrefixExtractor; - UndertowAccessLogCustomizer(ManagementServerProperties properties, Function accessLogPrefixExtractor) { - super(properties.getUndertow().getAccesslog().getPrefix()); + UndertowAccessLogCustomizer(UndertowManagementServerProperties properties, + Function accessLogPrefixExtractor) { + super(properties.getAccesslog().getPrefix()); this.accessLogPrefixExtractor = accessLogPrefixExtractor; } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerProperties.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerProperties.java new file mode 100644 index 0000000000..16d0af4046 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerProperties.java @@ -0,0 +1,53 @@ +/* + * Copyright 2012-2025 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.actuate.autoconfigure.web.server.undertow; + +import org.springframework.boot.context.properties.ConfigurationProperties; + +/** + * Properties for an Undertow-based management server. + * + * @author Moritz Halbritter + * @since 4.0.0 + */ +@ConfigurationProperties("management.server.undertow") +public class UndertowManagementServerProperties { + + private final Accesslog accesslog = new Accesslog(); + + public Accesslog getAccesslog() { + return this.accesslog; + } + + public static class Accesslog { + + /** + * Management log file name prefix. + */ + private String prefix = "management_"; + + public String getPrefix() { + return this.prefix; + } + + public void setPrefix(String prefix) { + this.prefix = prefix; + } + + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowReactiveManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowReactiveManagementChildContextConfiguration.java index aed23a71ea..c8190b54f6 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowReactiveManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowReactiveManagementChildContextConfiguration.java @@ -22,7 +22,6 @@ import org.springframework.boot.WebApplicationType; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextFactory; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; @@ -41,7 +40,7 @@ import org.springframework.context.annotation.Bean; */ @ConditionalOnClass(Undertow.class) @ConditionalOnWebApplication(type = Type.REACTIVE) -@EnableConfigurationProperties(ManagementServerProperties.class) +@EnableConfigurationProperties(UndertowManagementServerProperties.class) @ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) class UndertowReactiveManagementChildContextConfiguration { @@ -53,7 +52,7 @@ class UndertowReactiveManagementChildContextConfiguration { @Bean UndertowAccessLogCustomizer undertowManagementAccessLogCustomizer( - ManagementServerProperties properties) { + UndertowManagementServerProperties properties) { return new UndertowAccessLogCustomizer<>(properties, UndertowReactiveWebServerFactory::getAccessLogPrefix); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowServletManagementChildContextConfiguration.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowServletManagementChildContextConfiguration.java index 65699855b7..20d922622c 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowServletManagementChildContextConfiguration.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowServletManagementChildContextConfiguration.java @@ -20,7 +20,6 @@ import io.undertow.Undertow; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration; import org.springframework.boot.actuate.autoconfigure.web.ManagementContextType; -import org.springframework.boot.actuate.autoconfigure.web.server.ManagementServerProperties; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication; import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type; @@ -37,13 +36,13 @@ import org.springframework.context.annotation.Bean; */ @ConditionalOnClass(Undertow.class) @ConditionalOnWebApplication(type = Type.SERVLET) -@EnableConfigurationProperties(ManagementServerProperties.class) +@EnableConfigurationProperties(UndertowManagementServerProperties.class) @ManagementContextConfiguration(value = ManagementContextType.CHILD, proxyBeanMethods = false) class UndertowServletManagementChildContextConfiguration { @Bean UndertowAccessLogCustomizer undertowManagementAccessLogCustomizer( - ManagementServerProperties properties) { + UndertowManagementServerProperties properties) { return new UndertowAccessLogCustomizer<>(properties, UndertowServletWebServerFactory::getAccessLogPrefix); } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java index 46edd410c2..abb4b9d535 100644 --- a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/ManagementServerPropertiesTests.java @@ -69,12 +69,4 @@ class ManagementServerPropertiesTests { assertThat(properties.getBasePath()).isEmpty(); } - @Test - void accessLogsArePrefixedByDefault() { - ManagementServerProperties properties = new ManagementServerProperties(); - assertThat(properties.getTomcat().getAccesslog().getPrefix()).isEqualTo("management_"); - assertThat(properties.getJetty().getAccesslog().getPrefix()).isEqualTo("management_"); - assertThat(properties.getUndertow().getAccesslog().getPrefix()).isEqualTo("management_"); - } - } diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerPropertiesTests.java new file mode 100644 index 0000000000..d9425f8bf6 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/jetty/JettyManagementServerPropertiesTests.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-2025 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.actuate.autoconfigure.web.server.jetty; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link JettyManagementServerProperties}. + * + * @author Andy Wilkinson + */ +class JettyManagementServerPropertiesTests { + + @Test + void accessLogsArePrefixedByDefault() { + JettyManagementServerProperties properties = new JettyManagementServerProperties(); + assertThat(properties.getAccesslog().getPrefix()).isEqualTo("management_"); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerPropertiesTests.java new file mode 100644 index 0000000000..35bb466ec4 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/tomcat/TomcatManagementServerPropertiesTests.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-2025 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.actuate.autoconfigure.web.server.tomcat; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link TomcatManagementServerProperties}. + * + * @author Andy Wilkinson + */ +class TomcatManagementServerPropertiesTests { + + @Test + void accessLogsArePrefixedByDefault() { + TomcatManagementServerProperties properties = new TomcatManagementServerProperties(); + assertThat(properties.getAccesslog().getPrefix()).isEqualTo("management_"); + } + +} diff --git a/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerPropertiesTests.java b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerPropertiesTests.java new file mode 100644 index 0000000000..115f134128 --- /dev/null +++ b/spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/server/undertow/UndertowManagementServerPropertiesTests.java @@ -0,0 +1,36 @@ +/* + * Copyright 2012-2025 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.actuate.autoconfigure.web.server.undertow; + +import org.junit.jupiter.api.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Tests for {@link UndertowManagementServerProperties}. + * + * @author Andy Wilkinson + */ +class UndertowManagementServerPropertiesTests { + + @Test + void accessLogsArePrefixedByDefault() { + UndertowManagementServerProperties properties = new UndertowManagementServerProperties(); + assertThat(properties.getAccesslog().getPrefix()).isEqualTo("management_"); + } + +}