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

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

Lines changed: 2 additions & 1 deletion
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,

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

Lines changed: 4 additions & 1 deletion
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

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

Lines changed: 3 additions & 1 deletion
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

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

Lines changed: 3 additions & 1 deletion
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;

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

Lines changed: 2 additions & 1 deletion
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,

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

Lines changed: 1 addition & 0 deletions
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()

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

Lines changed: 3 additions & 0 deletions
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));

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

Lines changed: 1 addition & 0 deletions
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;

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

Lines changed: 1 addition & 0 deletions
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("/")

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

Lines changed: 2 additions & 0 deletions
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
}

0 commit comments

Comments
 (0)