Skip to content

Regression: InjectionMetadata cache needs to handle different bean classes per bean name [SPR-11246] #15871

Closed
@spring-projects-issues

Description

@spring-projects-issues

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:

Referenced from: commits 5c3f6a1, 5308b3e, 08aa22f, b146074

Backported to: 3.2.7

Metadata

Metadata

Assignees

Labels

status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions