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

Inconsistent dependency injection of proxied bean [SPR-9322] #13960

Closed
spring-issuemaster opened this issue Apr 11, 2012 · 1 comment
Closed

Inconsistent dependency injection of proxied bean [SPR-9322] #13960

spring-issuemaster opened this issue Apr 11, 2012 · 1 comment
Assignees

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Apr 11, 2012

Milan Skuhra opened SPR-9322 and commented

I tried to inject collection of beans (services) twice, into two beans (registers); and every register has injected different count of services.
Proxied bean was missing in second injection. It happend when first injection occurs and injecting proxied bean isn't created yet.

I debug it and found that method org.springframework.beans.factory.support.AbstractBeanFactory.isTypeMatch(..) has critical role in decision process if proxied bean will be injected or not.
If first injection occurs and proxied bean is not created yet, then method isTypeMatch(..) check injection suitability according to bean definition. Of course the proxied bean must be created to complete injection but apparently nothing check if type criteria is still matching after creation. When second injection occurs instance is already available and method isTypeMatch(..) check injection suitability according to instance - because it's a proxy it can return different result (as was in my case).

I attached simple project with one test case where this specific case is simulated. Of course there are many possibilities to fix it, but when somebody else accidentally configure something like this, it can be really hard to find where is the problem.

I suggest to duplicate condition (about suitability of bean to be injected) also after its creation.
If condition changes, exclude it from candidates and log some warning message.


Affects: 3.1.1

Attachments:

2 votes, 2 watchers

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Dec 26, 2018

Sébastien Deleuze commented

I tested the repro project with Spring Framework 5.1.3 and com.profiprog.sample.TestInjectection#test is green, so I resolve this issue as invalid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.