diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java index 037ac5734ea..5676bc693ca 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java @@ -466,8 +466,8 @@ public abstract class EndpointDiscoverer, O exten ExtensionBean(String beanName, Object bean) { this.bean = bean; this.beanName = beanName; - MergedAnnotation extensionAnnotation = MergedAnnotations.from(bean.getClass()) - .get(EndpointExtension.class); + MergedAnnotation extensionAnnotation = MergedAnnotations + .from(bean.getClass(), SearchStrategy.TYPE_HIERARCHY).get(EndpointExtension.class); Class endpointType = extensionAnnotation.getClass("endpoint"); MergedAnnotation endpointAnnotation = MergedAnnotations .from(endpointType, SearchStrategy.TYPE_HIERARCHY).get(Endpoint.class); diff --git a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java index 565d191f299..11c08155ea6 100644 --- a/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java +++ b/spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java @@ -44,6 +44,8 @@ import org.springframework.boot.actuate.endpoint.invoke.ParameterValueMapper; import org.springframework.boot.actuate.endpoint.invoke.convert.ConversionServiceParameterValueMapper; import org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvoker; import org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvokerAdvisor; +import org.springframework.cglib.proxy.Enhancer; +import org.springframework.cglib.proxy.FixedValue; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -236,6 +238,15 @@ class EndpointDiscovererTests { }); } + @Test + void getEndpointsWhenHasProxiedEndpointShouldReturnEndpoint() { + load(ProxiedSpecializedEndpointsConfiguration.class, (context) -> { + SpecializedEndpointDiscoverer discoverer = new SpecializedEndpointDiscoverer(context); + Map endpoints = mapEndpoints(discoverer.getEndpoints()); + assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"), EndpointId.of("specialized")); + }); + } + @Test void getEndpointsShouldApplyFilters() { load(SpecializedEndpointsConfiguration.class, (context) -> { @@ -327,6 +338,19 @@ class EndpointDiscovererTests { } + @Configuration(proxyBeanMethods = false) + static class ProxiedSpecializedTestEndpointConfiguration { + + @Bean + SpecializedExtension specializedExtension() { + Enhancer enhancer = new Enhancer(); + enhancer.setSuperclass(SpecializedExtension.class); + enhancer.setCallback((FixedValue) () -> null); + return (SpecializedExtension) enhancer.create(); + } + + } + @Configuration(proxyBeanMethods = false) static class TestEndpointConfiguration { @@ -387,6 +411,11 @@ class EndpointDiscovererTests { } + @Import({ TestEndpoint.class, SpecializedTestEndpoint.class, ProxiedSpecializedTestEndpointConfiguration.class }) + static class ProxiedSpecializedEndpointsConfiguration { + + } + @Endpoint(id = "test") static class TestEndpoint {