Commit e4d5714d authored by Phillip Webb's avatar Phillip Webb

Polish "Skip scoped targets when determining endpoints"

See gh-15182
parent 4853e6a7
......@@ -131,8 +131,8 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, 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,
......
......@@ -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<TestExposableEndpoint> 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<TestExposableEndpoint> endpoints = new TestEndpointDiscoverer(
context).getEndpoints();
assertThat(endpoints).flatExtracting(TestExposableEndpoint::getEndpointBean)
.containsOnly(expectedEndpoint);
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment