diff --git a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java index 293d9e437b..a771146f38 100644 --- a/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java +++ b/spring-aop/src/main/java/org/springframework/aop/framework/autoproxy/AutoProxyUtils.java @@ -94,14 +94,14 @@ public abstract class AutoProxyUtils { } /** - * Expose the given target class for the specified bean. + * Expose the given target class for the specified bean, if possible. * @param beanFactory the containing ConfigurableListableBeanFactory * @param beanName the name of the bean * @param targetClass the corresponding target class * @since 4.2.3 */ static void exposeTargetClass(ConfigurableListableBeanFactory beanFactory, String beanName, Class targetClass) { - if (beanFactory.containsBeanDefinition(beanName)) { + if (beanName != null && beanFactory.containsBeanDefinition(beanName)) { beanFactory.getMergedBeanDefinition(beanName).setAttribute(ORIGINAL_TARGET_CLASS_ATTRIBUTE, targetClass); } }