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

Transients not properly autowired on subsequent get #420

Closed
seancorfield opened this issue Jan 25, 2016 · 2 comments
Closed

Transients not properly autowired on subsequent get #420

seancorfield opened this issue Jan 25, 2016 · 2 comments
Assignees
Milestone

Comments

@seancorfield
Copy link
Member

See aliaspooryorik@3a038bc

@aliaspooryorik says "I think what happens is that when you call getBean on subsequent requests for a transient, it's wiring up the object using the info from variables.accumulatorCache, but doesn't return that instance (or something like that)"

@seancorfield seancorfield self-assigned this Jan 25, 2016
@seancorfield seancorfield added this to the 4.0 milestone Jan 25, 2016
@georgebridgeman
Copy link

From what I have found, the issue is caused by the setters being called on injection.bean but in the case of transients, that reference never updated after it has been instantiated the first time. The first instance is then held in variables.accumulatorCache['myTransient'].injection['myTransient'], and the setters are called on that instance on subsequent calls, but a different instance is returned.

I fixed the issue by putting this code in resolveBeanCreate, just below accumulator.bean = bean; on line 894:

if(!isSingleton(beanName) && structKeyExists(accumulator.injection, beanName)) {
    accumulator.injection[beanName].bean = accumulator.bean;
}

I'm not convinced that this is the correct fix though - smells very hacky - so haven't submitted a PR. I didn't have this issue with previous releases either, so I think the problem is caused elsewhere and my fix merely masks the issue.

@seancorfield
Copy link
Member Author

Thanks @georgebridgeman -- that's actually very helpful. The reason this bug has appeared is the caching code added to try to avoid walking dependencies multiple times for transients by not forcing regeneration of the accumulator data, but this seems to be a path through where the newly generated transient needs to be overridden in the cache (although there's still a possibility of multiple transients generated in a single recursive resolution phase where only one of them would have setters called properly... that may be enough of an edge case not to worry about).

aliaspooryorik added a commit to aliaspooryorik/fw1 that referenced this issue Jan 26, 2016
aliaspooryorik added a commit to aliaspooryorik/fw1 that referenced this issue Jan 26, 2016
aliaspooryorik added a commit to aliaspooryorik/fw1 that referenced this issue Jan 26, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants