Merge pull request #17807 from jebeaudet
* pr/17807: Polish "Fix annotation lookup on proxied EndpointExtension" Fix annotation lookup on proxied EndpointExtension Closes gh-17807
This commit is contained in:
@@ -469,8 +469,8 @@ public abstract class EndpointDiscoverer<E extends ExposableEndpoint<O>, O exten
|
||||
ExtensionBean(String beanName, Object bean) {
|
||||
this.bean = bean;
|
||||
this.beanName = beanName;
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.getMergedAnnotationAttributes(bean.getClass(),
|
||||
EndpointExtension.class);
|
||||
AnnotationAttributes attributes = AnnotatedElementUtils.findMergedAnnotationAttributes(bean.getClass(),
|
||||
EndpointExtension.class, false, true);
|
||||
Class<?> endpointType = attributes.getClass("endpoint");
|
||||
AnnotationAttributes endpointAttributes = AnnotatedElementUtils.findMergedAnnotationAttributes(endpointType,
|
||||
Endpoint.class, true, true);
|
||||
|
||||
@@ -44,6 +44,8 @@ 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.cglib.proxy.Enhancer;
|
||||
import org.springframework.cglib.proxy.FixedValue;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
@@ -236,6 +238,15 @@ public class EndpointDiscovererTests {
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEndpointsWhenHasProxiedEndpointShouldReturnEndpoint() {
|
||||
load(ProxiedSpecializedEndpointsConfiguration.class, (context) -> {
|
||||
SpecializedEndpointDiscoverer discoverer = new SpecializedEndpointDiscoverer(context);
|
||||
Map<EndpointId, SpecializedExposableEndpoint> endpoints = mapEndpoints(discoverer.getEndpoints());
|
||||
assertThat(endpoints).containsOnlyKeys(EndpointId.of("test"), EndpointId.of("specialized"));
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getEndpointsShouldApplyFilters() {
|
||||
load(SpecializedEndpointsConfiguration.class, (context) -> {
|
||||
@@ -327,6 +338,19 @@ public class EndpointDiscovererTests {
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class ProxiedSpecializedTestEndpointConfiguration {
|
||||
|
||||
@Bean
|
||||
public SpecializedExtension specializedExtension() {
|
||||
Enhancer enhancer = new Enhancer();
|
||||
enhancer.setSuperclass(SpecializedExtension.class);
|
||||
enhancer.setCallback((FixedValue) () -> null);
|
||||
return (SpecializedExtension) enhancer.create();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Configuration
|
||||
static class TestEndpointConfiguration {
|
||||
|
||||
@@ -387,6 +411,11 @@ public class EndpointDiscovererTests {
|
||||
|
||||
}
|
||||
|
||||
@Import({ TestEndpoint.class, SpecializedTestEndpoint.class, ProxiedSpecializedTestEndpointConfiguration.class })
|
||||
static class ProxiedSpecializedEndpointsConfiguration {
|
||||
|
||||
}
|
||||
|
||||
@Endpoint(id = "test")
|
||||
static class TestEndpoint {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user