-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Consider defaultCandidate for scoped proxies #35627
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
Conversation
default boolean isDefaultCandidate() { | ||
return true; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This lines could have an impact. Declaration as "default" should be maximal transparent, but this is a central interface. Not necessarily required, could also be solved another way (see my other comments). But I think, this is straight and clear.
// Copy autowire settings from original bean definition. | ||
proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate()); | ||
proxyDefinition.setPrimary(targetDefinition.isPrimary()); | ||
proxyDefinition.setDefaultCandidate(targetDefinition.isDefaultCandidate()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the extension fo the BeanDefinition-Interface is not acceptable, then setting the "defaultCandidate-Property" could also take place by checking/casting as in line 85 below:
proxyDefinition.setDefaultCandidate(abd.isDefaultCandidate());
// The target bean should be ignored in favor of the scoped proxy. | ||
targetDefinition.setAutowireCandidate(false); | ||
targetDefinition.setPrimary(false); | ||
targetDefinition.setDefaultCandidate(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with this line:
Alternative: add after line 86/87: abd.setDefaultCandidate(false)
Signed-off-by: Schäfer, H.H. (Hans Hosea) <HansHosea.Schaefer@ing.de>
Update `OnBeanCondition` to check the scoped proxy target for `isDefaultCandidate`. This fixes an issue introduced by spring-projects/spring-framework#35627. Fixes gh-47633
PR for #35626