Only proxy supported beans in BeanNameAutoProxyCreator
Prior to this commit, if a BeanNameAutoProxyCreator was configured with a custom TargetSourceCreator, the TargetSourceCreator was applied to all beans in the ApplicationContext. Thus, the list of supported beanNames was effectively ignored when applying any TargetSourceCreator. Consequently, if a TargetSourceCreator returned a non-null TargetSource for a given bean, the BeanNameAutoProxyCreator proxied the bean even if the bean name had not been configured in the beanNames list. This commit addresses this issue by ensuring that a custom TargetSourceCreator is only applied to beans whose names match the configured beanNames list in a BeanNameAutoProxyCreator. Closes gh-24915
This commit is contained in:
@@ -104,4 +104,28 @@
|
||||
<property name="name" value="noproxy" />
|
||||
</bean>
|
||||
|
||||
<bean id="lazy1" class="org.springframework.beans.testfixture.beans.TestBean" lazy-init="true">
|
||||
<property name="name" value="lazy1" />
|
||||
</bean>
|
||||
|
||||
<alias name="lazy1" alias="lazy1alias"/>
|
||||
|
||||
<bean id="lazy2" class="org.springframework.beans.testfixture.beans.TestBean" lazy-init="true">
|
||||
<property name="name" value="lazy2" />
|
||||
</bean>
|
||||
|
||||
<bean id="lazyBeanNameAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
|
||||
<property name="beanNames" value="lazy1" />
|
||||
<property name="customTargetSourceCreators">
|
||||
<bean class="org.springframework.aop.framework.autoproxy.target.LazyInitTargetSourceCreator" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="lazyAliasBeanNameAutoProxyCreator" class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
|
||||
<property name="beanNames" value="lazy1alias" />
|
||||
<property name="customTargetSourceCreators">
|
||||
<bean class="org.springframework.aop.framework.autoproxy.target.LazyInitTargetSourceCreator" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
||||
|
||||
Reference in New Issue
Block a user