Skip to content

DefaultSingletonBeanRegistry::getSingleton(String beanName) attempts to create bean when it shouldn't [SPR-10674] #15302

Closed
@spring-projects-issues

Description

@spring-projects-issues

manny veloso opened SPR-10674 and commented

According to the docs, getSingleton(String beanName) is not supposed to attempt to create the singleton if it doesn't exist.

"Only checks already instantiated singletons; does not return an Object for singleton bean definitions which have not been instantiated yet."

However, the code calls getSingleton(beanName, true). Calling getSingleton(beanName, true) attempts to create the bean if not found in the registry.

Note that a quick search through the spring sources show that the usage of getSingleton(String beanName) is consistent with the documentation ie: code that uses getSingleton(beanName) attempts to create the bean if null is returned from the function. In addition, one other use checks the existence of the bean in the registry before trying to retriev eit.


Affects: 3.1.4, 3.2.3

Issue Links:

Metadata

Metadata

Assignees

Labels

status: invalidAn issue that we don't feel is valid

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions