Skip to content

Commit 647a5ec

Browse files
committed
Deprecate framework-specific @*Endpoint annotations
Prior to this commit, applications could declare Actuator Endpoints using web framework-specific annotations, such as `@ServletEndpoint`, @ControllerEndpoint and @RestControllerEndpoint. Such annotations are closely tied to the programming model of specific web technologies, such as Servlet or Spring MVC. Unlike other `@Endpoint` support, they are not portable and will not work transparently over blocking/reactive and transports. Because of the strong adherence of this support with the underlying infrastructure, it makes it impossible to evolve the implementation of Actuator support without breaking this use case. The reference documentation has been advocating for using `@Endpoint` and `@*Operation` for custom endpoints for a long time now. This commit deprecates this specific support in favor of the recommended approach. Closes gh-31768
1 parent 34c6075 commit 647a5ec

File tree

44 files changed

+91
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+91
-47
lines changed

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/cloudfoundry/servlet/CloudFoundryActuatorAutoConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -111,6 +111,7 @@ public CloudFoundryInfoEndpointWebExtension cloudFoundryInfoEndpointWebExtension
111111
}
112112

113113
@Bean
114+
@SuppressWarnings("removal")
114115
public CloudFoundryWebEndpointServletHandlerMapping cloudFoundryWebEndpointServletHandlerMapping(
115116
ParameterValueMapper parameterMapper, EndpointMediaTypes endpointMediaTypes,
116117
RestTemplateBuilder restTemplateBuilder, ServletEndpointsSupplier servletEndpointsSupplier,

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfiguration.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -47,6 +47,7 @@
4747
public class ServletEndpointManagementContextConfiguration {
4848

4949
@Bean
50+
@SuppressWarnings("removal")
5051
public IncludeExcludeEndpointFilter<ExposableServletEndpoint> servletExposeExcludePropertyEndpointFilter(
5152
WebEndpointProperties properties) {
5253
WebEndpointProperties.Exposure exposure = properties.getExposure();
@@ -56,6 +57,7 @@ public IncludeExcludeEndpointFilter<ExposableServletEndpoint> servletExposeExclu
5657

5758
@Configuration(proxyBeanMethods = false)
5859
@ConditionalOnClass(DispatcherServlet.class)
60+
@SuppressWarnings("removal")
5961
public static class WebMvcServletEndpointManagementContextConfiguration {
6062

6163
@Bean
@@ -70,6 +72,7 @@ public ServletEndpointRegistrar servletEndpointRegistrar(WebEndpointProperties p
7072
@Configuration(proxyBeanMethods = false)
7173
@ConditionalOnClass(ResourceConfig.class)
7274
@ConditionalOnMissingClass("org.springframework.web.servlet.DispatcherServlet")
75+
@SuppressWarnings("removal")
7376
public static class JerseyServletEndpointManagementContextConfiguration {
7477

7578
@Bean

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfiguration.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -96,6 +96,7 @@ public WebEndpointDiscoverer webEndpointDiscoverer(ParameterValueMapper paramete
9696

9797
@Bean
9898
@ConditionalOnMissingBean(ControllerEndpointsSupplier.class)
99+
@SuppressWarnings("removal")
99100
public ControllerEndpointDiscoverer controllerEndpointDiscoverer(ObjectProvider<PathMapper> endpointPathMappers,
100101
ObjectProvider<Collection<EndpointFilter<ExposableControllerEndpoint>>> filters) {
101102
return new ControllerEndpointDiscoverer(this.applicationContext, endpointPathMappers.orderedStream().toList(),
@@ -124,6 +125,7 @@ public IncludeExcludeEndpointFilter<ExposableControllerEndpoint> controllerExpos
124125

125126
@Configuration(proxyBeanMethods = false)
126127
@ConditionalOnWebApplication(type = Type.SERVLET)
128+
@SuppressWarnings("removal")
127129
static class WebEndpointServletConfiguration {
128130

129131
@Bean

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/jersey/JerseyWebEndpointManagementContextConfiguration.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -84,6 +84,7 @@ class JerseyWebEndpointManagementContextConfiguration {
8484
private static final EndpointId HEALTH_ENDPOINT_ID = EndpointId.of("health");
8585

8686
@Bean
87+
@SuppressWarnings("removal")
8788
JerseyWebEndpointsResourcesRegistrar jerseyWebEndpointsResourcesRegistrar(Environment environment,
8889
WebEndpointsSupplier webEndpointsSupplier, ServletEndpointsSupplier servletEndpointsSupplier,
8990
EndpointMediaTypes endpointMediaTypes, WebEndpointProperties webEndpointProperties) {
@@ -124,6 +125,7 @@ private boolean shouldRegisterLinksMapping(WebEndpointProperties properties, Env
124125
/**
125126
* Register endpoints with the {@link ResourceConfig} for the management context.
126127
*/
128+
@SuppressWarnings("removal")
127129
static class JerseyWebEndpointsResourcesRegistrar implements ManagementContextResourceConfigCustomizer {
128130

129131
private final WebEndpointsSupplier webEndpointsSupplier;

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/main/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/servlet/WebMvcEndpointManagementContextConfiguration.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -82,6 +82,7 @@ public class WebMvcEndpointManagementContextConfiguration {
8282

8383
@Bean
8484
@ConditionalOnMissingBean
85+
@SuppressWarnings("removal")
8586
public WebMvcEndpointHandlerMapping webEndpointServletHandlerMapping(WebEndpointsSupplier webEndpointsSupplier,
8687
ServletEndpointsSupplier servletEndpointsSupplier, ControllerEndpointsSupplier controllerEndpointsSupplier,
8788
EndpointMediaTypes endpointMediaTypes, CorsEndpointProperties corsProperties,

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/ServletEndpointManagementContextConfigurationTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
* @author Phillip Webb
4343
* @author Madhura Bhave
4444
*/
45+
@SuppressWarnings("removal")
4546
class ServletEndpointManagementContextConfigurationTests {
4647

4748
private final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/endpoint/web/WebEndpointAutoConfigurationTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ void webApplicationSupportCustomPathMatcher() {
9595
}
9696

9797
@Test
98+
@SuppressWarnings("removal")
9899
void webApplicationConfiguresEndpointDiscoverer() {
99100
this.contextRunner.run((context) -> {
100101
assertThat(context).hasSingleBean(ControllerEndpointDiscoverer.class);
@@ -109,11 +110,13 @@ void webApplicationConfiguresExposeExcludePropertyEndpointFilter() {
109110
}
110111

111112
@Test
113+
@SuppressWarnings("removal")
112114
void contextShouldConfigureServletEndpointDiscoverer() {
113115
this.contextRunner.run((context) -> assertThat(context).hasSingleBean(ServletEndpointDiscoverer.class));
114116
}
115117

116118
@Test
119+
@SuppressWarnings("removal")
117120
void contextWhenNotServletShouldNotConfigureServletEndpointDiscoverer() {
118121
new ApplicationContextRunner().withConfiguration(CONFIGURATIONS)
119122
.run((context) -> assertThat(context).doesNotHaveBean(ServletEndpointDiscoverer.class));

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebFluxIntegrationTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
*
4646
* @author Phillip Webb
4747
*/
48+
@SuppressWarnings("removal")
4849
class ControllerEndpointWebFluxIntegrationTests {
4950

5051
private AnnotationConfigReactiveWebApplicationContext context;

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/ControllerEndpointWebMvcIntegrationTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ static class SecureConfiguration {
121121
}
122122

123123
@RestControllerEndpoint(id = "example")
124+
@SuppressWarnings("removal")
124125
static class ExampleController {
125126

126127
@GetMapping("/")

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/JerseyEndpointIntegrationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,13 @@ private Class<?>[] getAutoconfigurations(Class<?>... additional) {
161161
}
162162

163163
@ControllerEndpoint(id = "controller")
164+
@SuppressWarnings("removal")
164165
static class TestControllerEndpoint {
165166

166167
}
167168

168169
@RestControllerEndpoint(id = "restcontroller")
170+
@SuppressWarnings("removal")
169171
static class TestRestControllerEndpoint {
170172

171173
}

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebFluxEndpointIntegrationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,13 @@ private WebTestClient createWebTestClient(ApplicationContext context) {
108108
}
109109

110110
@ControllerEndpoint(id = "controller")
111+
@SuppressWarnings("removal")
111112
static class TestControllerEndpoint {
112113

113114
}
114115

115116
@RestControllerEndpoint(id = "restcontroller")
117+
@SuppressWarnings("removal")
116118
static class TestRestControllerEndpoint {
117119

118120
}

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointExposureIntegrationTests.java

+2
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ private boolean isExposed(WebTestClient client, HttpMethod method, String path)
190190
}
191191

192192
@RestControllerEndpoint(id = "custommvc")
193+
@SuppressWarnings("removal")
193194
static class CustomMvcEndpoint {
194195

195196
@GetMapping("/")
@@ -200,6 +201,7 @@ String main() {
200201
}
201202

202203
@ServletEndpoint(id = "customservlet")
204+
@SuppressWarnings("removal")
203205
static class CustomServletEndpoint implements Supplier<EndpointServlet> {
204206

205207
@Override

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/integrationtest/WebMvcEndpointIntegrationTests.java

+3
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ static class SecureConfiguration {
198198
}
199199

200200
@ServletEndpoint(id = "servlet")
201+
@SuppressWarnings("removal")
201202
static class TestServletEndpoint implements Supplier<EndpointServlet> {
202203

203204
@Override
@@ -209,11 +210,13 @@ public EndpointServlet get() {
209210
}
210211

211212
@ControllerEndpoint(id = "controller")
213+
@SuppressWarnings("removal")
212214
static class TestControllerEndpoint {
213215

214216
}
215217

216218
@RestControllerEndpoint(id = "restcontroller")
219+
@SuppressWarnings("removal")
217220
static class TestRestControllerEndpoint {
218221

219222
}

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/reactive/EndpointRequestTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ static class FooEndpoint {
355355
}
356356

357357
@ServletEndpoint(id = "baz")
358+
@SuppressWarnings("removal")
358359
static class BazServletEndpoint {
359360

360361
}

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/AbstractEndpointRequestIntegrationTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ Object getAll() {
178178
}
179179

180180
@ServletEndpoint(id = "se1")
181+
@SuppressWarnings("removal")
181182
static class TestServletEndpoint implements Supplier<EndpointServlet> {
182183

183184
@Override

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/security/servlet/EndpointRequestTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ static class FooEndpoint {
354354
}
355355

356356
@ServletEndpoint(id = "baz")
357+
@SuppressWarnings("removal")
357358
static class BazServletEndpoint {
358359

359360
}

Diff for: spring-boot-project/spring-boot-actuator-autoconfigure/src/test/java/org/springframework/boot/actuate/autoconfigure/web/servlet/WebMvcEndpointChildContextConfigurationIntegrationTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ String fail() {
217217
}
218218

219219
@RestControllerEndpoint(id = "failController")
220+
@SuppressWarnings("removal")
220221
static class FailingControllerEndpoint {
221222

222223
@GetMapping

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/EndpointServlet.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -33,7 +33,9 @@
3333
* @author Phillip Webb
3434
* @author Julio José Gómez Díaz
3535
* @since 2.0.0
36+
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
3637
*/
38+
@Deprecated(since = "3.3.0", forRemoval = true)
3739
public final class EndpointServlet {
3840

3941
private final Servlet servlet;

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ExposableServletEndpoint.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -24,7 +24,10 @@
2424
*
2525
* @author Phillip Webb
2626
* @since 2.0.0
27+
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
2728
*/
29+
@Deprecated(since = "3.3.0", forRemoval = true)
30+
@SuppressWarnings("removal")
2831
public interface ExposableServletEndpoint extends ExposableEndpoint<Operation>, PathMappedEndpoint {
2932

3033
/**

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/ServletEndpointRegistrar.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -35,7 +35,10 @@
3535
* @author Phillip Webb
3636
* @author Madhura Bhave
3737
* @since 2.0.0
38+
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint} support
3839
*/
40+
@Deprecated(since = "3.3.0", forRemoval = true)
41+
@SuppressWarnings("removal")
3942
public class ServletEndpointRegistrar implements ServletContextInitializer {
4043

4144
private static final Log logger = LogFactory.getLog(ServletEndpointRegistrar.class);

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpoint.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2021 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -47,12 +47,14 @@
4747
* @since 2.0.0
4848
* @see WebEndpoint
4949
* @see RestControllerEndpoint
50+
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint}
5051
*/
5152
@Target(ElementType.TYPE)
5253
@Retention(RetentionPolicy.RUNTIME)
5354
@Documented
5455
@Endpoint
5556
@FilteredEndpoint(ControllerEndpointFilter.class)
57+
@Deprecated(since = "3.3.0", forRemoval = true)
5658
public @interface ControllerEndpoint {
5759

5860
/**

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointDiscoverer.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 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.
@@ -31,7 +31,6 @@
3131
import org.springframework.boot.actuate.endpoint.invoke.OperationInvoker;
3232
import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper;
3333
import org.springframework.boot.actuate.endpoint.web.PathMapper;
34-
import org.springframework.boot.actuate.endpoint.web.annotation.ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints;
3534
import org.springframework.context.ApplicationContext;
3635
import org.springframework.context.annotation.ImportRuntimeHints;
3736
import org.springframework.core.annotation.MergedAnnotations;
@@ -43,8 +42,11 @@
4342
*
4443
* @author Phillip Webb
4544
* @since 2.0.0
45+
* @deprecated since 3.3.0 in favor of {@code @Endpoint} and {@code @WebEndpoint} support
4646
*/
47-
@ImportRuntimeHints(ControllerEndpointDiscovererRuntimeHints.class)
47+
@ImportRuntimeHints(ControllerEndpointDiscoverer.ControllerEndpointDiscovererRuntimeHints.class)
48+
@Deprecated(since = "3.3.0", forRemoval = true)
49+
@SuppressWarnings("removal")
4850
public class ControllerEndpointDiscoverer extends EndpointDiscoverer<ExposableControllerEndpoint, Operation>
4951
implements ControllerEndpointsSupplier {
5052

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/ControllerEndpointFilter.java

+2-1
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-2024 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.
@@ -25,6 +25,7 @@
2525
*
2626
* @author Phillip Webb
2727
*/
28+
@SuppressWarnings("removal")
2829
class ControllerEndpointFilter extends DiscovererEndpointFilter {
2930

3031
ControllerEndpointFilter() {

Diff for: spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/annotation/DiscoveredServletEndpoint.java

+2-1
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-2024 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.
@@ -32,6 +32,7 @@
3232
*
3333
* @author Phillip Webb
3434
*/
35+
@SuppressWarnings("removal")
3536
class DiscoveredServletEndpoint extends AbstractDiscoveredEndpoint<Operation> implements ExposableServletEndpoint {
3637

3738
private final String rootPath;

0 commit comments

Comments
 (0)