Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spring beans in singleton scope are ignoring default component-scan scoped-proxy configuration [SPR-6683] #11349

Closed
spring-projects-issues opened this issue Jan 13, 2010 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

Mauricio Noda opened SPR-6683 and commented

<context:component-scan base-package="somePackage" scoped-proxy="targetClass" />

It doesn´t matter what is configured in the scoped-proxy attribute, singleton scoped beans defaults to "no" and they have to be all configured explicity in a one-by-one basis using @Scope(proxyMode = TARGET_CLASS).

It generates a lot of annoying java.io.NotSerializableException in common web applications until all singletons are found and have their proxyMode attribute set.


Affects: 3.0 GA

Referenced from: commits abdc35c, 56d2c9d

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

There is a backwards compatibility problem hiding here: In Spring 2.5, we had scoped proxies technically only working for non-singleton beans (that aside, the containing BeanFactory wasn't serializable, so singleton beans couldn't actually benefit from a scoped proxy).

For Spring 3.0(.1), I opted for a compromise now: Component classes which are explicitly annotated with @Scope("singleton") - or custom scope annotations which happen to be meta-annotated with @Scope("singleton") - are eligible for component-scan's scoped-proxy setting. After all, their scope annotation indicates ScopedProxyMode.DEFAULT since Spring 3.0 and hence suggests the use of component-scan's setting. However, component classes with no scope annotations at all do still not qualify: They will be defaulted to singletons but will never receive a scoped proxy.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Mauricio Noda commented

This issue should have been reported earlier, before Spring 3.0.0 was released. Then compatibility would less of an issue.

Thanks anyway.

@spring-projects-issues spring-projects-issues added type: enhancement A general enhancement in: core Issues in core modules (aop, beans, core, context, expression) labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.0.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants