BeanFactoryAdvisorRetrievalHelper avoids synchronization for name cache
Issue: SPR-16570
This commit is contained in:
parent
47d8fe83df
commit
7f1a8d78b5
|
|
@ -45,7 +45,7 @@ public class BeanFactoryAdvisorRetrievalHelper {
|
||||||
private final ConfigurableListableBeanFactory beanFactory;
|
private final ConfigurableListableBeanFactory beanFactory;
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private String[] cachedAdvisorBeanNames;
|
private volatile String[] cachedAdvisorBeanNames;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -66,16 +66,13 @@ public class BeanFactoryAdvisorRetrievalHelper {
|
||||||
*/
|
*/
|
||||||
public List<Advisor> findAdvisorBeans() {
|
public List<Advisor> findAdvisorBeans() {
|
||||||
// Determine list of advisor bean names, if not cached already.
|
// Determine list of advisor bean names, if not cached already.
|
||||||
String[] advisorNames = null;
|
String[] advisorNames = this.cachedAdvisorBeanNames;
|
||||||
synchronized (this) {
|
if (advisorNames == null) {
|
||||||
advisorNames = this.cachedAdvisorBeanNames;
|
// Do not initialize FactoryBeans here: We need to leave all regular beans
|
||||||
if (advisorNames == null) {
|
// uninitialized to let the auto-proxy creator apply to them!
|
||||||
// Do not initialize FactoryBeans here: We need to leave all regular beans
|
advisorNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
|
||||||
// uninitialized to let the auto-proxy creator apply to them!
|
this.beanFactory, Advisor.class, true, false);
|
||||||
advisorNames = BeanFactoryUtils.beanNamesForTypeIncludingAncestors(
|
this.cachedAdvisorBeanNames = advisorNames;
|
||||||
this.beanFactory, Advisor.class, true, false);
|
|
||||||
this.cachedAdvisorBeanNames = advisorNames;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (advisorNames.length == 0) {
|
if (advisorNames.length == 0) {
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue