Skip to content

Commit

Permalink
Don't syncrhonize the entire loading operation. Fixes #2867
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskleeh committed May 1, 2020
1 parent 1a11892 commit f4ba006
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1810,9 +1810,7 @@ protected void processParallelBeans() {
parallelBeans.forEach(beanDefinitionReference -> {
try {
if (isRunning()) {
synchronized (singletonObjects) {
loadContextScopeBean(beanDefinitionReference, parallelDefinitions::add);
}
loadContextScopeBean(beanDefinitionReference, parallelDefinitions::add);
}
} catch (Throwable e) {
LOG.error("Parallel Bean definition [" + beanDefinitionReference.getName() + "] could not be loaded: " + e.getMessage(), e);
Expand All @@ -1829,9 +1827,7 @@ protected void processParallelBeans() {
parallelDefinitions.forEach(beanDefinition -> ForkJoinPool.commonPool().execute(() -> {
try {
if (isRunning()) {
synchronized (singletonObjects) {
loadContextScopeBean(beanDefinition);
}
loadContextScopeBean(beanDefinition);
}
} catch (Throwable e) {
LOG.error("Parallel Bean definition [" + beanDefinition.getName() + "] could not be loaded: " + e.getMessage(), e);
Expand Down Expand Up @@ -1991,7 +1987,7 @@ private void loadContextScopeBean(BeanDefinition beanDefinition) {

} else {
try (BeanResolutionContext resolutionContext = newResolutionContext(beanDefinition, null)) {
createAndRegisterSingletonInternal(resolutionContext, beanDefinition, beanDefinition.getBeanType(), null);
createAndRegisterSingleton(resolutionContext, beanDefinition, beanDefinition.getBeanType(), null);
}
}
}
Expand Down

0 comments on commit f4ba006

Please sign in to comment.