Skip to content

Conversation

hosea
Copy link

@hosea hosea commented Oct 13, 2025

PR for #35626

default boolean isDefaultCandidate() {
return true;
}

Copy link
Author

@hosea hosea Oct 13, 2025

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Oct 13, 2025
// Copy autowire settings from original bean definition.
proxyDefinition.setAutowireCandidate(targetDefinition.isAutowireCandidate());
proxyDefinition.setPrimary(targetDefinition.isPrimary());
proxyDefinition.setDefaultCandidate(targetDefinition.isDefaultCandidate());
Copy link
Author

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);
Copy link
Author

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)

@hosea hosea changed the base branch from main to 6.2.x October 13, 2025 21:03
Signed-off-by: Schäfer, H.H. (Hans Hosea) <HansHosea.Schaefer@ing.de>
@jhoeller jhoeller self-assigned this Oct 14, 2025
@jhoeller jhoeller added type: bug A general bug in: core Issues in core modules (aop, beans, core, context, expression) and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Oct 14, 2025
@jhoeller jhoeller added this to the 6.2.12 milestone Oct 14, 2025
@jhoeller jhoeller changed the title 35626: defaultCandidate for scoped proxies Consider defaultCandidate for scoped proxies Oct 14, 2025
@jhoeller jhoeller merged commit df67c1c into spring-projects:6.2.x Oct 14, 2025
4 checks passed
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
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) type: bug A general bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants