The method getSingleton(String, ObjectFactory<?>) may throw a BeanCurrentlyInCreationException in multiple threads.

If Thread-A acquires the singletonLock, but before it assigns itself to singletonCreationThread, Thread-B gets a null value at singletonCreationThread, then Thread-A and Thread-B will both invoke beforeSingletonCreation.

In this commit, I remove the else, so the thread which does not acquire singletonLock will be blocked at the code this.singletonLock.lock().

Closes gh-33463

Comment From: pivotal-cla

@liuao1004 Please sign the Contributor License Agreement!

Click here to manually synchronize the status of this Pull Request.

See the FAQ for frequently asked questions.

Comment From: pivotal-cla

@liuao1004 Thank you for signing the Contributor License Agreement!

Comment From: jhoeller

That else block is necessary for the lenient locking as covered by BeanFactoryLockingTests. Instead, I am going with a larger revision that resolves #33463 through applying the lenient locking fallback to the singleton pre-instantiation phase during a coordinated bootstrap only, exposing concurrent scenarios after bootstrap (e.g. for lazy singletons) to a full singleton lock.