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 e153bfe85a..af195b3325 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 @@ -131,8 +131,8 @@ public abstract class EndpointDiscoverer, O exten String[] beanNames = BeanFactoryUtils.beanNamesForAnnotationIncludingAncestors( this.applicationContext, Endpoint.class); for (String beanName : beanNames) { - EndpointBean endpointBean = createEndpointBean(beanName); if (!ScopedProxyUtils.isScopedTarget(beanName)) { + EndpointBean endpointBean = createEndpointBean(beanName); EndpointBean previous = byId.putIfAbsent(endpointBean.getId(), endpointBean); Assert.state(previous == 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 1d8a0506fd..25c3d85606 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 @@ -46,7 +46,6 @@ 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.boot.actuate.endpoint.jmx.EndpointMBean; import org.springframework.context.ApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.Bean; @@ -151,13 +150,13 @@ public class EndpointDiscovererTests { @Test public void getEndpointsWhenEndpointsArePrefixedWithScopedTargetShouldRegisterOnlyOneEndpoint() { - load(ScopedTargetEndpointConfiguration.class, ( - context) -> { - Collection endpoints = - new TestEndpointDiscoverer(context).getEndpoints(); - assertThat(endpoints).hasSize(1); - assertThat(endpoints.iterator().next().getEndpointBean()).isSameAs(context - .getBean(ScopedTargetEndpointConfiguration.class).testEndpoint()); + load(ScopedTargetEndpointConfiguration.class, (context) -> { + TestEndpoint expectedEndpoint = context + .getBean(ScopedTargetEndpointConfiguration.class).testEndpoint(); + Collection endpoints = new TestEndpointDiscoverer( + context).getEndpoints(); + assertThat(endpoints).flatExtracting(TestExposableEndpoint::getEndpointBean) + .containsOnly(expectedEndpoint); }); }