Simplify getInternalBeanFactoryForBean

This commit simplifies getInternalBeanFactoryForBean() in
AbstractBeanFactoryBasedTargetSourceCreator via
Map::computeIfAbsent.

Closes gh-27234
This commit is contained in:
Anton Lyxell 2021-07-31 16:27:43 +02:00 committed by GitHub
parent bd1f5bd9fc
commit 01c8de0111
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 6 deletions

View File

@ -125,12 +125,7 @@ public abstract class AbstractBeanFactoryBasedTargetSourceCreator
*/
protected DefaultListableBeanFactory getInternalBeanFactoryForBean(String beanName) {
synchronized (this.internalBeanFactories) {
DefaultListableBeanFactory internalBeanFactory = this.internalBeanFactories.get(beanName);
if (internalBeanFactory == null) {
internalBeanFactory = buildInternalBeanFactory(this.beanFactory);
this.internalBeanFactories.put(beanName, internalBeanFactory);
}
return internalBeanFactory;
return this.internalBeanFactories.computeIfAbsent(beanName, k -> buildInternalBeanFactory(this.beanFactory));
}
}