Description
Ludovic Ronsin opened SPR-11246 and commented
In my project I use a request-scoped factory bean in order to inject the expected implementation between several beans (singletons) depending on request context.
So given a bean name, several candidates can be injected.
The InjectionMetadata cache in AutowiredAnnotationBeanPostProcessor use the bean name as a key. (See AutowiredAnnotationBeanPostProcessor.findAutowiringMetadata(String beanName, Class<?> clazz))
In my case it doesn't work because it doesn't always return the metadata of the corresponding class, instead it will always return the metadata of the first used class.
I attached a test project to reproduce this bug, just run the included junit test.
Seems to be reproducible since 3.2.5.RELEASE and still present on 4.0.0.RELEASE
Affects: 3.2.5, 4.0 GA
Issue Links:
- AutowireCapableBeanFactory no longer autowiring since version 3.2.5 [SPR-11230] #15855 AutowireCapableBeanFactory no longer autowiring since version 3.2.5
- Providing unique names to prototype inner beans causes excessive memory and CPU use [SPR-11545] #16170 Providing unique names to prototype inner beans causes excessive memory and CPU use
Referenced from: commits 5c3f6a1, 5308b3e, 08aa22f, b146074
Backported to: 3.2.7