Skip to content

Commit ce01f7f

Browse files
committed
Merge branch '2.1.x'
Closes gh-18882
2 parents a65374b + ed50bf2 commit ce01f7f

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscoverer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ Set<ExtensionBean> getExtensions() {
424424
}
425425

426426
private Class<?> getFilter(Class<?> type) {
427-
return MergedAnnotations.from(type).get(FilteredEndpoint.class)
427+
return MergedAnnotations.from(type, SearchStrategy.TYPE_HIERARCHY).get(FilteredEndpoint.class)
428428
.getValue(MergedAnnotation.VALUE, Class.class).orElse(null);
429429
}
430430

spring-boot-project/spring-boot-actuator/src/test/java/org/springframework/boot/actuate/endpoint/annotation/EndpointDiscovererTests.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,8 @@ void getEndpointsWhenHasSpecializedFiltersInSpecializedDiscovererShouldNotFilter
209209
load(SpecializedEndpointsConfiguration.class, (context) -> {
210210
SpecializedEndpointDiscoverer discoverer = new SpecializedEndpointDiscoverer(context);
211211
Map<EndpointId, SpecializedExposableEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
212-
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"), EndpointId.of("specialized"));
212+
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"), EndpointId.of("specialized"),
213+
EndpointId.of("specialized-superclass"));
213214
});
214215
}
215216

@@ -252,7 +253,7 @@ void getEndpointsShouldApplyFilters() {
252253
load(SpecializedEndpointsConfiguration.class, (context) -> {
253254
EndpointFilter<SpecializedExposableEndpoint> filter = (endpoint) -> {
254255
EndpointId id = endpoint.getEndpointId();
255-
return !id.equals(EndpointId.of("specialized"));
256+
return !id.equals(EndpointId.of("specialized")) && !id.equals(EndpointId.of("specialized-superclass"));
256257
};
257258
SpecializedEndpointDiscoverer discoverer = new SpecializedEndpointDiscoverer(context,
258259
Collections.singleton(filter));
@@ -401,7 +402,8 @@ TestEndpoint scopedTargetTestEndpoint() {
401402

402403
}
403404

404-
@Import({ TestEndpoint.class, SpecializedTestEndpoint.class, SpecializedExtension.class })
405+
@Import({ TestEndpoint.class, SpecializedTestEndpoint.class, SpecializedSuperclassTestEndpoint.class,
406+
SpecializedExtension.class })
405407
static class SpecializedEndpointsConfiguration {
406408

407409
}
@@ -494,6 +496,20 @@ Object getAll() {
494496

495497
}
496498

499+
@SpecializedEndpoint(id = "specialized-superclass")
500+
static class AbstractFilteredEndpoint {
501+
502+
}
503+
504+
static class SpecializedSuperclassTestEndpoint extends AbstractFilteredEndpoint {
505+
506+
@ReadOperation
507+
public Object getAll() {
508+
return null;
509+
}
510+
511+
}
512+
497513
static class SubSpecializedTestEndpoint extends SpecializedTestEndpoint {
498514

499515
@ReadOperation

0 commit comments

Comments
 (0)