Improve handling of mainThreadPrefix and remove redundant null check (#34746)

This commit is contained in:
Seonghun Jeong
2025-04-22 19:16:34 +09:00
committed by GitHub
parent fc516cb39e
commit d3a5aefdff

View File

@@ -1048,7 +1048,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
@Override
protected @Nullable Boolean isCurrentThreadAllowedToHoldSingletonLock() {
String mainThreadPrefix = this.mainThreadPrefix;
if (this.mainThreadPrefix != null) {
if (mainThreadPrefix != null) {
// We only differentiate in the preInstantiateSingletons phase.
PreInstantiation preInstantiation = this.preInstantiationThread.get();
@@ -1069,7 +1069,7 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
}
else if (this.strictLocking == null) {
// No explicit locking configuration -> infer appropriate locking.
if (mainThreadPrefix != null && !getThreadNamePrefix().equals(mainThreadPrefix)) {
if (!getThreadNamePrefix().equals(mainThreadPrefix)) {
// An unmanaged thread (assumed to be application-internal) with lenient locking,
// and not part of the same thread pool that provided the main bootstrap thread
// (excluding scenarios where we are hit by multiple external bootstrap threads).