Issue Details (XML | Word | Printable)

Key: SPR-3804
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Critical Critical
Assignee: Mark Fisher
Reporter: Dave Syer
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Spring Framework

Using aop:scoped-proxy introduces unwanted extra autowire candidate even with autowire-candidate="false"

Created: 25/Aug/07 11:35 AM   Updated: 25/Sep/07 04:19 PM
Component/s: SpringAOP
Affects Version/s: 1.0 M3, 2.0.6, 2.1 M3
Fix Version/s: 2.1 M4, 2.0.7

Time Tracking:
Not Specified

File Attachments: 1. Zip Archive scoped-proxy-test.zip (4 kB)



 Description  « Hide
Using aop:scoped-proxy introduces unwanted extra autowire candidate. E.g. with this

<bean id="parent" class="test.ScopedProxyTests$TestBean"
abstract="true">
<property name="name" value="foo" />
</bean>

<bean id="scoped" parent="parent" autowire-candidate="false"
scope="request">
<aop:scoped-proxy />
</bean>
<bean id="unscoped" parent="parent" />

I get two autowire candidates - the "unscoped" bean, and the auto proxy FactoryBean for the "scoped" version, even though the bean definition is marked as autowire-candidate="false".

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Dave Syer added a comment - 25/Aug/07 11:37 AM
Attached a test case that has an autowire error because of this issue.

Dave Syer added a comment - 26/Aug/07 02:19 AM
Manually setting up the factory bean works (instead of using aop:scoped-proxy):

<bean id="bean" parent="parent" autowire-candidate="false" scope="request"/>
<bean id="scoped" class="org.springframework.aop.scope.ScopedProxyFactoryBean" autowire-candidate="false">
<property name="proxyTargetClass" value="true"/>
<property name="targetBeanName" value="bean"/>
</bean>
<bean id="unscoped" parent="parent" />

so it seems the problem is with the bean definition decoration in aop:scoped-proxy.

Mark Fisher added a comment - 30/Aug/07 10:28 AM
The scoped-proxy bean that is generated for a bean definition decorated with <aop:scoped-proxy/> now inherits the target bean's original 'autowire-candidate' setting when explicitly set to false. The target bean definition itself is still set to 'false' regardless of the scoped-proxy (so that only the proxy is considered as an autowire candidate).

Juergen Hoeller added a comment - 25/Sep/07 04:19 PM
I've backported this to mbranch-2-0 now, so this fix is going to be part of the 2.0.7 release.

Juergen