Browse Source

Merge branch '6.2.x'

pull/35418/head
Juergen Hoeller 4 months ago
parent
commit
410eff641c
  1. 20
      spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultListableBeanFactory.java

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

@ -1099,11 +1099,10 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
List<String> beanNames = new ArrayList<>(this.beanDefinitionNames); List<String> beanNames = new ArrayList<>(this.beanDefinitionNames);
// Trigger initialization of all non-lazy singleton beans... // Trigger initialization of all non-lazy singleton beans...
List<CompletableFuture<?>> futures = new ArrayList<>();
this.preInstantiationThread.set(PreInstantiation.MAIN); this.preInstantiationThread.set(PreInstantiation.MAIN);
this.mainThreadPrefix = getThreadNamePrefix(); this.mainThreadPrefix = getThreadNamePrefix();
try { try {
List<CompletableFuture<?>> futures = new ArrayList<>();
for (String beanName : beanNames) { for (String beanName : beanNames) {
RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName); RootBeanDefinition mbd = getMergedLocalBeanDefinition(beanName);
if (!mbd.isAbstract() && mbd.isSingleton()) { if (!mbd.isAbstract() && mbd.isSingleton()) {
@ -1113,21 +1112,20 @@ public class DefaultListableBeanFactory extends AbstractAutowireCapableBeanFacto
} }
} }
} }
if (!futures.isEmpty()) {
try {
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).join();
}
catch (CompletionException ex) {
ReflectionUtils.rethrowRuntimeException(ex.getCause());
}
}
} }
finally { finally {
this.mainThreadPrefix = null; this.mainThreadPrefix = null;
this.preInstantiationThread.remove(); this.preInstantiationThread.remove();
} }
if (!futures.isEmpty()) {
try {
CompletableFuture.allOf(futures.toArray(new CompletableFuture<?>[0])).join();
}
catch (CompletionException ex) {
ReflectionUtils.rethrowRuntimeException(ex.getCause());
}
}
// Trigger post-initialization callback for all applicable beans... // Trigger post-initialization callback for all applicable beans...
for (String beanName : beanNames) { for (String beanName : beanNames) {
Object singletonInstance = getSingleton(beanName, false); Object singletonInstance = getSingleton(beanName, false);

Loading…
Cancel
Save