Skip to content

Commit 410eff6

Browse files
committed
Merge branch '6.2.x'
2 parents e53e413 + 3a4315b commit 410eff6

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,11 +1099,10 @@ public void preInstantiateSingletons() throws BeansException {
10991099
List<String> beanNames = new ArrayList<>(this.beanDefinitionNames);
11001100

11011101
// Trigger initialization of all non-lazy singleton beans...
1102-
List<CompletableFuture<?>> futures = new ArrayList<>();
1103-
11041102
this.preInstantiationThread.set(PreInstantiation.MAIN);
11051103
this.mainThreadPrefix = getThreadNamePrefix();
11061104
try {
1105+
List<CompletableFuture<?>> futures = new ArrayList<>();
11071106
for (String beanName : beanNames) {
11081107
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
11091108
if (!mbd.isAbstract() && mbd.isSingleton()) {
@@ -1113,21 +1112,20 @@ public void preInstantiateSingletons() throws BeansException {
11131112
}
11141113
}
11151114
}
1115+
if (!futures.isEmpty()) {
1116+
try {
1117+
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).join();
1118+
}
1119+
catch (CompletionException ex) {
1120+
ReflectionUtils.rethrowRuntimeException(ex.getCause());
1121+
}
1122+
}
11161123
}
11171124
finally {
11181125
this.mainThreadPrefix = null;
11191126
this.preInstantiationThread.remove();
11201127
}
11211128

1122-
if (!futures.isEmpty()) {
1123-
try {
1124-
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).join();
1125-
}
1126-
catch (CompletionException ex) {
1127-
ReflectionUtils.rethrowRuntimeException(ex.getCause());
1128-
}
1129-
}
1130-
11311129
// Trigger post-initialization callback for all applicable beans...
11321130
for (String beanName : beanNames) {
11331131
Object singletonInstance = getSingleton(beanName, false);

0 commit comments

Comments
 (0)