BeanCurrentlyInCreationException
is thrown when multiple threads get a bean from StaticApplicationContext
's Bean Factory
#33463
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
type: regression
A bug that is also a regression
Milestone
Affects: 6.2.0-M7
After updating to the latest milestone version (6.2.0-M7), an
org.springframework.beans.factory.BeanCurrentlyInCreationException
is thrown when getting a bean frombeanFactory
ofStaticApplicationContext
. Race conditions take place when multiple threads are involved.Apparently,
DefaultSingletonBeanRegistry#getSingleton(String beanName, ObjectFactory<?> singletonFactory)
is the method where the following scenario takes place:beforeSingletonCreation(beanName)
is called in Thread A,beforeSingletonCreation(beanName)
is called in Thread B,afterSingletonCreation(String beanName)
has not yet been called in Thread A, the above step will cause race condition and throwing ofBeanCurrentlyInCreationException
.Notes
DefaultSingletonBeanRegistry
directly instead of throughStaticApplicationContext
, then no exception is thrown.Minimal example (might require several runs)
Traces for
testRaceCondition
The text was updated successfully, but these errors were encountered: