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 a1ff0f54af..61e93126d9 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 @@ -423,8 +423,8 @@ public abstract class EndpointDiscoverer, O exten } private Class getFilter(Class type) { - AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(type, - FilteredEndpoint.class); + AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(type, + FilteredEndpoint.class, false, true); if (attributes == null) { return null; } 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 94a8f065ec..6154cd9ba6 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 @@ -209,7 +209,8 @@ public class EndpointDiscovererTests { load(SpecializedEndpointsConfiguration.class, (context) -> { SpecializedEndpointDiscoverer discoverer = new SpecializedEndpointDiscoverer(context); Map endpoints = mapEndpoints(discoverer.getEndpoints()); - assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"), EndpointId.of("specialized")); + assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"), EndpointId.of("specialized"), + EndpointId.of("specialized-superclass")); }); } @@ -252,7 +253,7 @@ public class EndpointDiscovererTests { load(SpecializedEndpointsConfiguration.class, (context) -> { EndpointFilter filter = (endpoint) -> { EndpointId id = endpoint.getEndpointId(); - return !id.equals(EndpointId.of("specialized")); + return !id.equals(EndpointId.of("specialized")) && !id.equals(EndpointId.of("specialized-superclass")); }; SpecializedEndpointDiscoverer discoverer = new SpecializedEndpointDiscoverer(context, Collections.singleton(filter)); @@ -401,7 +402,8 @@ public class EndpointDiscovererTests { } - @Import({ TestEndpoint.class, SpecializedTestEndpoint.class, SpecializedExtension.class }) + @Import({ TestEndpoint.class, SpecializedTestEndpoint.class, SpecializedSuperclassTestEndpoint.class, + SpecializedExtension.class }) static class SpecializedEndpointsConfiguration { } @@ -494,6 +496,20 @@ public class EndpointDiscovererTests { } + @SpecializedEndpoint(id = "specialized-superclass") + static class AbstractFilteredEndpoint { + + } + + static class SpecializedSuperclassTestEndpoint extends AbstractFilteredEndpoint { + + @ReadOperation + public Object getAll() { + return null; + } + + } + static class SubSpecializedTestEndpoint extends SpecializedTestEndpoint { @ReadOperation