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

Provide variant of ListableBeanFactory.getBeanNamesForAnnotation that does not cause early BeanFactory initialization #31658

Closed
philwebb opened this issue Nov 22, 2023 · 2 comments
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement

Comments

@philwebb
Copy link
Member

See spring-projects/spring-boot#38473 for background.

We'd basically like a new method where this call passes in a allowFactoryBeanInit parameter.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Nov 22, 2023
@jhoeller
Copy link
Contributor

Since that affects Boot 3.1.x, I assume you expect such a method to become available in Framework 6.0.x?

@jhoeller
Copy link
Contributor

Since getBeanNamesForAnnotation is effectively just a loop around findAnnotationOnBean, this can also be quite easily done externally: Take getBeanNamesIterator() and then call the allowFactoryBeanInit-enabled findAnnotationOnBean variant from there. Alternatively, you could keep doing separate beanDefinitionNames+singletonNames iteration as in the recent commit.

Since we would not only have to add a corresponding getBeanNamesForAnnotation variant but also an overloaded getBeansWithAnnotation variant for completeness, I'm inclined to suggest the external iteration approach instead. Not only for Boot 3.1.x but also for Boot 3.2 going forward.

@jhoeller jhoeller added status: declined A suggestion or change that we don't feel we should currently apply in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Nov 23, 2023
@sbrannen sbrannen closed this as not planned Won't fix, can't repro, duplicate, stale Nov 23, 2023
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) status: declined A suggestion or change that we don't feel we should currently apply type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants