Skip to content

DefaultListableBeanFactory.getBeanNamesForAnnotation : Improve javadoc [SPR-17392] #21925

@spring-projects-issues

Description

@spring-projects-issues

Philipp Foermer opened SPR-17392 and commented

For "org.springframework.beans.factory.support.DefaultListableBeanFactory" the javadoc of

public java.lang.String[] getBeanNamesForAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)

defines:

Find all names of beans whose Class has the supplied Annotation type, without creating any bean instances yet.

It would be nice, if the wording is precised, as a registered FactoryBean BeanDefinition is eagerly initialized, if the method is invoked.

I noticed this unexpected behaviour in a custom @Conditional Condition implementation, causing broken factory bean instances, because required preconditions have not been initialized before factory bean was eagerly initialized.

It seems that the eager initialization issue as been worked around in "org.springframework.boot.autoconfigure.condition.BeanTypeRegistry" by missing this case.


Affects: 4.3.17

Referenced from: commits 5a6c081, cd66467, da23505

Backported to: 5.0.11, 4.3.21

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)status: backportedAn issue that has been backported to maintenance branchestype: taskA general task

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions