-
Notifications
You must be signed in to change notification settings - Fork 38.5k
@Autowired setter randomly called twice or not called at all when two beans of the same class [SPR-11027] #15655
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
Comments
Piotr Findeisen commented Repro project spring-attic/spring-framework-issues#60 For me, it fails on Spring 3.1.2, 3.1.4. |
Piotr Findeisen commented 3.2.4 is affected too. |
Juergen Hoeller commented Indeed, this may happen if there are several beans of the same Class, with a property being overridden on one such bean but not the others. I've changed the caching to a bean name key instead of a Class key. To be released in 4.0 RC1 as well as 3.2.5 next week. Juergen |
Piotr Findeisen commented Hi Juergen Hoeller, Thanks for fixing this. |
Juergen Hoeller commented Piotr, there won't be any further 3.1.x releases. We consider the 3.2 line as a direct continuation of the 3.1 line, with as smooth an upgrade path as a a 3.1.5 release would be. So please upgrade to Spring Framework 3.2.5; if there any unexpected issues with the upgrade, let us know. Note that Spring 3.2 has the same system requirements and full backwards compatibility with 3.1. Actually, 3.2 is the first generation of Spring with full runtime support for the 1.7 bytecode level; so if you're on Java 7, I would strongly recommend an upgrade to Spring 3.2 in any case. Juergen |
Piotr Findeisen commented Hi, Thanks for the explanation. I've already once attempted upgrade from 3.1.2 to 3.1.4 (because of #15585), but I was defeated by #15623. I will check on Monday whether #15623 still affects 3.2.4 (i.e. latest released 3.2). Piotr |
Juergen Hoeller commented Piotr, as just mentioned in #15623, I'm about to fix that one through a backport to 3.2.5. So I hope there's nothing preventing you from an upgrade eventually. Juergen |
Piotr Findeisen commented
Hi, I see 3.2.5 delayed until today (JIRA says "Release Date: 06/Nov/13"). Is it indeed going to be released today or is it a 'moving target'? |
Juergen Hoeller commented Hi Piotr, this is indeed scheduled for release today (US time); so it should be available tomorrow morning (European time). You could test our latest 3.2.5 snapshot in the meantime, if you like :-) Juergen |
Piotr Findeisen opened SPR-11027 and commented
According to docs,
@Autowired
setter should not be called when an explicit value is set in XML context configuration.Unfortunately, the
AutowiredAnnotationBeanPostProcessor.injectionMetadataCache
cache is per Class, but it's contents, especiallyAutowiredMethodElement.skip
attribute (inherited byAutowiredMethodElement
from superclass) is specific bean definition dependent.As a result, if I have two unrelated beans of the same class, they 'share' their autowiring behavior.
@Autowired
may have its setter not called at all@Autowired
setter may have its setter called twiceAffects: 3.1.2, 3.1.4, 3.2.4
Referenced from: commits ce001c2, 4675bc4, 393cfcf
The text was updated successfully, but these errors were encountered: