Skip to content

Dependency Injection issue when using ManagedMap or ManagedList in BeanDefinitionParser [SPR-11131] #15757

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

Closed
spring-projects-issues opened this issue Nov 27, 2013 · 2 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Nov 27, 2013

Chris Mathews opened SPR-11131 and commented

I just hit an issue when upgrading one of my projects from Spring 3.2.4 to 3.2.5. Here is the basic scenario simplified down to the core details:

  • Implemented a custom Spring namespace
  • Programatically wiring up a bean class, let's call it WidgetRegistry that maintains a Map<String, WidgetStack>
  • The WidgetStack instances are also programatically wired in the namespace and they maintain a List<Widget>.
  • The Widget is a simple class that has one member variable injected on it using @Inject.

I have tested this scenario from 3.0.0 all the way up to 3.2.4 and everything works as expected (4.0.0.M1 - M3 also work). When I upgrade to 3.2.5, 4.0.0.RC1 or 4.0.0-SNAPSHOT however things explode. The problem is that the Widget instances (inside the List) are no longer being injected upon. To be more exact only the first element (index 0) is not being injected upon... the rest of the Widget instances are being fully populated. This also only occurs when implemented as part of a custom namespace using ManagedMap and ManagedList to wire the appropriate Collections. If I wire the beans explicitly in Spring xml then everything works as expected.

Attached is a small sample project I threw together to demonstrate the problem.


Affects: 3.2.5, 4.0 RC1

Attachments:

Issue Links:

Referenced from: commits 242ecdc, d0fc38e

Backported to: 3.2.6

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

This turned out to be a side effect of our change towards bean-specific caching in AutowiredAnnotationBeanPostProcessor and co, instead of the previous class-based caching. There was one scenario that we missed: Inner beans with multi-level nesting like in your case, which led to the reuse of the same inner bean name and hence to an misplaced cache hit... A problem that we always had but never discovered before relying on those bean names for caching.

Anyway, fixed for 4.0 GA and 3.2.6 now. Thanks for the timely report!

Juergen

@spring-projects-issues
Copy link
Collaborator Author

Chris Mathews commented

I tested my internal project against both 3.2.6.BUILD-SNAPSHOT and 4.0.0.BUILD-SNAPSHOT and everything works as expected now. Thanks Juergen!

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches 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 4.0 GA 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) status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants