Polish "Skip scoped targets when determining endpoints"

See gh-15182
pull/16246/head
Phillip Webb 6 years ago
parent 4853e6a7af
commit e4d5714d50

@ -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);
});
}

Loading…
Cancel
Save