Skip to content

@Inject Provider or @Autowired ObjectFactory issue with session scoped bean [SPR-9181] #13819

@spring-projects-issues

Description

@spring-projects-issues

Greg Thompson opened SPR-9181 and commented

I have a session scoped bean. It's marked with <aop:scoped-proxy />. I'm trying to inject a Provider or ObjectFactory into the session bean using @Inject or @Autowired. It injects fine the first time the session bean is created. On the second creation of the session bean (for a 2nd session), I get java.lang.IllegalArgumentException when setting the @Inject or @Autowired property. It's trying to set the actual bean, instead of a provider or an object factory.

I stepped through the code. The code in the getDependencyType() method of DependencyDescriptor doesn't seem to work as expected when it's setting the value on the second session bean. Something with the nesting level. So, I don't get a DependencyProvider as expected in the resolveDependency method of DefaultListableBeanFactory class. The getDependencyType returns the class of the bean, instead of a provider or object factory class that is the type of the property.

This worked fine with 3.0.


Attachments:

Issue Links:

Referenced from: commits 1bd775f, fbe955a

6 votes, 8 watchers

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: regressionA bug that is also a regression

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions