@@ -1113,11 +1113,10 @@ public void preInstantiateSingletons() throws BeansException {
1113
1113
List <String > beanNames = new ArrayList <>(this .beanDefinitionNames );
1114
1114
1115
1115
// Trigger initialization of all non-lazy singleton beans...
1116
- List <CompletableFuture <?>> futures = new ArrayList <>();
1117
-
1118
1116
this .preInstantiationThread .set (PreInstantiation .MAIN );
1119
1117
this .mainThreadPrefix = getThreadNamePrefix ();
1120
1118
try {
1119
+ List <CompletableFuture <?>> futures = new ArrayList <>();
1121
1120
for (String beanName : beanNames ) {
1122
1121
RootBeanDefinition mbd = getMergedLocalBeanDefinition (beanName );
1123
1122
if (!mbd .isAbstract () && mbd .isSingleton ()) {
@@ -1127,21 +1126,20 @@ public void preInstantiateSingletons() throws BeansException {
1127
1126
}
1128
1127
}
1129
1128
}
1129
+ if (!futures .isEmpty ()) {
1130
+ try {
1131
+ CompletableFuture .allOf (futures .toArray (new CompletableFuture <?>[0 ])).join ();
1132
+ }
1133
+ catch (CompletionException ex ) {
1134
+ ReflectionUtils .rethrowRuntimeException (ex .getCause ());
1135
+ }
1136
+ }
1130
1137
}
1131
1138
finally {
1132
1139
this .mainThreadPrefix = null ;
1133
1140
this .preInstantiationThread .remove ();
1134
1141
}
1135
1142
1136
- if (!futures .isEmpty ()) {
1137
- try {
1138
- CompletableFuture .allOf (futures .toArray (new CompletableFuture <?>[0 ])).join ();
1139
- }
1140
- catch (CompletionException ex ) {
1141
- ReflectionUtils .rethrowRuntimeException (ex .getCause ());
1142
- }
1143
- }
1144
-
1145
1143
// Trigger post-initialization callback for all applicable beans...
1146
1144
for (String beanName : beanNames ) {
1147
1145
Object singletonInstance = getSingleton (beanName , false );
0 commit comments