You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Note that getSingleton only allows for access to "early bean references", i.e. early access to a bean if it happens to be part of a circular reference. There is an explicit check that we're only attempting this for beans which are currently "in creation": This means that the bean kind-of exists already, its instance just hasn't been made available yet since it isn't fully constructed yet - and therefore only made available if a circular reference requires it.
In that sense, the present code is fine as-is for the intended use cases, including the getSingleton(String) variant, to the best of my understanding.
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:
The text was updated successfully, but these errors were encountered: