Merge branch '6.2.x'

This commit is contained in:
Juergen Hoeller
2025-04-07 22:42:52 +02:00
4 changed files with 46 additions and 34 deletions

View File

@@ -313,7 +313,7 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
while ((singletonObject = this.singletonObjects.get(beanName)) == null) {
Thread otherThread = this.currentCreationThreads.get(beanName);
if (otherThread != null && (otherThread == currentThread ||
this.lenientWaitingThreads.get(otherThread) == currentThread)) {
checkDependentWaitingThreads(otherThread, currentThread))) {
throw ex;
}
if (!this.singletonsInLenientCreation.contains(beanName)) {
@@ -429,6 +429,16 @@ public class DefaultSingletonBeanRegistry extends SimpleAliasRegistry implements
}
}
private boolean checkDependentWaitingThreads(Thread waitingThread, Thread candidateThread) {
Thread threadToCheck = waitingThread;
while ((threadToCheck = this.lenientWaitingThreads.get(threadToCheck)) != null) {
if (threadToCheck == candidateThread) {
return true;
}
}
return false;
}
/**
* Determine whether the current thread is allowed to hold the singleton lock.
* <p>By default, any thread may acquire and hold the singleton lock, except