From 4e131bd627bdbaee8516b05b6d585f7be0521237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Thu, 20 Oct 2022 18:08:04 +0200 Subject: [PATCH] Provide a workaround to allow multiple @ImportRuntimeHints Provide a workaround for spring-projects/spring-framework#29361 so that multiple `@ImportRuntimeHints` can be used in a type hierarchy. The commit should cover Actuator web endpoint use cases with the exception of Cloud Foundry endpoints which are not possible due to package access issues. See gh-29361 --- .../endpoint/web/reactive/WebFluxEndpointHandlerMapping.java | 4 +++- .../endpoint/web/servlet/WebMvcEndpointHandlerMapping.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointHandlerMapping.java index aafa6c707b2..51c1145094a 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/reactive/WebFluxEndpointHandlerMapping.java @@ -31,6 +31,7 @@ import org.springframework.boot.actuate.endpoint.web.EndpointMapping; import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes; import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint; import org.springframework.boot.actuate.endpoint.web.Link; +import org.springframework.boot.actuate.endpoint.web.reactive.AbstractWebFluxEndpointHandlerMapping.AbstractWebFluxEndpointHandlerMappingRuntimeHints; import org.springframework.boot.actuate.endpoint.web.reactive.WebFluxEndpointHandlerMapping.WebFluxEndpointHandlerMappingRuntimeHints; import org.springframework.context.annotation.ImportRuntimeHints; import org.springframework.web.bind.annotation.ResponseBody; @@ -48,7 +49,8 @@ import org.springframework.web.util.UriComponentsBuilder; * @author Brian Clozel * @since 2.0.0 */ -@ImportRuntimeHints(WebFluxEndpointHandlerMappingRuntimeHints.class) +@ImportRuntimeHints({ WebFluxEndpointHandlerMappingRuntimeHints.class, + AbstractWebFluxEndpointHandlerMappingRuntimeHints.class }) public class WebFluxEndpointHandlerMapping extends AbstractWebFluxEndpointHandlerMapping implements InitializingBean { private final EndpointLinksResolver linksResolver; diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java index 180a378bbe9..8c107485801 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java @@ -33,6 +33,7 @@ import org.springframework.boot.actuate.endpoint.web.EndpointMapping; import org.springframework.boot.actuate.endpoint.web.EndpointMediaTypes; import org.springframework.boot.actuate.endpoint.web.ExposableWebEndpoint; import org.springframework.boot.actuate.endpoint.web.Link; +import org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.AbstractWebMvcEndpointHandlerMappingRuntimeHints; import org.springframework.boot.actuate.endpoint.web.servlet.WebMvcEndpointHandlerMapping.WebMvcEndpointHandlerMappingRuntimeHints; import org.springframework.context.annotation.ImportRuntimeHints; import org.springframework.web.bind.annotation.ResponseBody; @@ -47,7 +48,8 @@ import org.springframework.web.servlet.HandlerMapping; * @author Phillip Webb * @since 2.0.0 */ -@ImportRuntimeHints(WebMvcEndpointHandlerMappingRuntimeHints.class) +@ImportRuntimeHints({ WebMvcEndpointHandlerMappingRuntimeHints.class, + AbstractWebMvcEndpointHandlerMappingRuntimeHints.class }) public class WebMvcEndpointHandlerMapping extends AbstractWebMvcEndpointHandlerMapping { private final EndpointLinksResolver linksResolver;