Always preserve target class for configuration classes in case of auto-proxying
Issue: SPR-10561
This commit is contained in:
@@ -20,6 +20,11 @@ import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.aop.Pointcut;
|
||||
import org.springframework.aop.aspectj.annotation.AnnotationAwareAspectJAutoProxyCreator;
|
||||
import org.springframework.aop.interceptor.SimpleTraceInterceptor;
|
||||
import org.springframework.aop.support.DefaultPointcutAdvisor;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -127,6 +132,16 @@ public class BeanMethodPolymorphismTests {
|
||||
assertThat(ctx.getBean(String.class), equalTo("shadow"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void beanMethodThroughAopProxy() {
|
||||
AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
|
||||
ctx.register(Config.class);
|
||||
ctx.register(AnnotationAwareAspectJAutoProxyCreator.class);
|
||||
ctx.register(TestAdvisor.class);
|
||||
ctx.refresh();
|
||||
ctx.getBean("testBean", TestBean.class);
|
||||
}
|
||||
|
||||
|
||||
@Configuration
|
||||
static class BaseConfig {
|
||||
@@ -239,4 +254,12 @@ public class BeanMethodPolymorphismTests {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class TestAdvisor extends DefaultPointcutAdvisor {
|
||||
|
||||
public TestAdvisor() {
|
||||
super(new SimpleTraceInterceptor());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user