Consider defaultCandidate for scoped proxies#35627
Merged
Merged
Conversation
hosea
commented
Oct 13, 2025
| default boolean isDefaultCandidate() { | ||
| return true; | ||
| } | ||
|
|
Author
There was a problem hiding this comment.
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.
hosea
commented
Oct 13, 2025
| // Copy autowire settings from original bean definition. | ||
| proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate()); | ||
| proxyDefinition.setPrimary(targetDefinition.isPrimary()); | ||
| proxyDefinition.setDefaultCandidate(targetDefinition.isDefaultCandidate()); |
Author
There was a problem hiding this comment.
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());
hosea
commented
Oct 13, 2025
| // The target bean should be ignored in favor of the scoped proxy. | ||
| targetDefinition.setAutowireCandidate(false); | ||
| targetDefinition.setPrimary(false); | ||
| targetDefinition.setDefaultCandidate(false); |
Author
There was a problem hiding this comment.
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>
jhoeller
added a commit
that referenced
this pull request
Oct 14, 2025
philwebb
added a commit
to spring-projects/spring-boot
that referenced
this pull request
Oct 14, 2025
Update `OnBeanCondition` to check the scoped proxy target for `isDefaultCandidate`. This fixes an issue introduced by spring-projects/spring-framework#35627. Fixes gh-47633
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR for #35626