Ignore resolved bean from non-active scope in getIfAvailable/getIfUnique

Closes gh-24822
This commit is contained in:
Juergen Hoeller
2020-05-13 19:25:20 +02:00
parent a3c5625d4e
commit 5de6ae6fca
7 changed files with 239 additions and 52 deletions

View File

@@ -1,8 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="requestScopedObject" class="org.springframework.beans.testfixture.beans.TestBean" scope="request">
<property name="name" value="#{request.contextPath}"/>
@@ -12,6 +11,8 @@
<bean id="requestScopedFactoryBean" class="org.springframework.beans.testfixture.beans.factory.DummyFactory" scope="request"/>
<bean id="requestScopedUniqueBean" class="org.springframework.beans.testfixture.beans.CountingTestBean" scope="request"/>
<bean id="requestScopedObjectCircle1" class="org.springframework.beans.testfixture.beans.TestBean" scope="request">
<property name="spouse" ref="requestScopedObjectCircle2"/>
</bean>
@@ -20,22 +21,22 @@
<property name="spouse" ref="requestScopedObjectCircle1"/>
</bean>
<bean id="requestScopedOuterBean" class="org.springframework.beans.testfixture.beans.DerivedTestBean" scope="request">
<property name="name" value="outer"/>
<property name="spouse">
<bean class="org.springframework.beans.testfixture.beans.DerivedTestBean">
<property name="name" value="inner"/>
</bean>
</property>
</bean>
<bean id="requestScopedOuterBean" class="org.springframework.beans.testfixture.beans.DerivedTestBean" scope="request">
<property name="name" value="outer"/>
<property name="spouse">
<bean class="org.springframework.beans.testfixture.beans.DerivedTestBean">
<property name="name" value="inner"/>
</bean>
</property>
</bean>
<bean id="singletonOuterBean" class="org.springframework.beans.testfixture.beans.DerivedTestBean" lazy-init="true">
<property name="name" value="outer"/>
<property name="spouse">
<bean class="org.springframework.beans.testfixture.beans.DerivedTestBean" scope="request">
<property name="name" value="inner"/>
</bean>
</property>
</bean>
<bean id="singletonOuterBean" class="org.springframework.beans.testfixture.beans.DerivedTestBean" lazy-init="true">
<property name="name" value="outer"/>
<property name="spouse">
<bean class="org.springframework.beans.testfixture.beans.DerivedTestBean" scope="request">
<property name="name" value="inner"/>
</bean>
</property>
</bean>
</beans>

View File

@@ -24,6 +24,10 @@
<aop:scoped-proxy/>
</bean>
<bean id="requestScopedUniqueBean" class="org.springframework.beans.testfixture.beans.CountingTestBean" scope="request">
<aop:scoped-proxy/>
</bean>
<bean id="requestScopedObjectCircle1" class="org.springframework.beans.testfixture.beans.TestBean" scope="request">
<aop:scoped-proxy/>
<property name="spouse" ref="requestScopedObjectCircle2"/>