mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Leniently tolerate null bean as aspect instance
Closes gh-35074
This commit is contained in:
+20
@@ -364,6 +364,16 @@ class AspectJAutoProxyCreatorTests {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void nullAdviceIsSkipped() {
|
||||
try (ConfigurableApplicationContext context = new AnnotationConfigApplicationContext(ProxyWithNullAdviceConfig.class)) {
|
||||
@SuppressWarnings("unchecked")
|
||||
Supplier<String> supplier = context.getBean(Supplier.class);
|
||||
assertThat(AopUtils.isAopProxy(supplier)).as("AOP proxy").isTrue();
|
||||
assertThat(supplier.get()).isEqualTo("lambda");
|
||||
}
|
||||
}
|
||||
|
||||
private ClassPathXmlApplicationContext newContext(String fileSuffix) {
|
||||
return new ClassPathXmlApplicationContext(getClass().getSimpleName() + "-" + fileSuffix, getClass());
|
||||
}
|
||||
@@ -627,6 +637,16 @@ class ProxyTargetClassFalseConfig extends AbstractProxyTargetClassConfig {
|
||||
class ProxyTargetClassTrueConfig extends AbstractProxyTargetClassConfig {
|
||||
}
|
||||
|
||||
@Configuration(proxyBeanMethods = false)
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||
class ProxyWithNullAdviceConfig extends AbstractProxyTargetClassConfig {
|
||||
|
||||
@Override
|
||||
SupplierAdvice supplierAdvice() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Configuration
|
||||
@EnableAspectJAutoProxy(proxyTargetClass = true)
|
||||
class PerTargetProxyTargetClassTrueConfig {
|
||||
|
||||
Reference in New Issue
Block a user