This commit is contained in:
Albumen Kevin 2024-06-26 05:53:51 +00:00 committed by GitHub
commit 0f67e08d45
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 11 deletions

View File

@ -148,7 +148,7 @@ public class ReferenceBean<T>
private MutablePropertyValues propertyValues;
// actual reference config
private ReferenceConfig referenceConfig;
private volatile ReferenceConfig referenceConfig;
// ReferenceBeanManager
private ReferenceBeanManager referenceBeanManager;
@ -423,15 +423,22 @@ public class ReferenceBean<T>
private Object getCallProxy() throws Exception {
if (referenceConfig == null) {
referenceBeanManager.initReferenceBean(this);
applicationContext
.getBean(DubboConfigApplicationListener.class.getName(), DubboConfigApplicationListener.class)
.init();
logger.warn(
CONFIG_DUBBO_BEAN_INITIALIZER,
"",
"",
"ReferenceBean is not ready yet, please make sure to call reference interface method after dubbo is started.");
synchronized (LockUtils.getSingletonMutex(applicationContext)) {
if (referenceConfig == null) {
referenceBeanManager.initReferenceBean(this);
applicationContext
.getBean(
DubboConfigApplicationListener.class.getName(),
DubboConfigApplicationListener.class)
.init();
logger.warn(
CONFIG_DUBBO_BEAN_INITIALIZER,
"",
"",
"ReferenceBean is not ready yet, please make sure to "
+ "call reference interface method after dubbo is started.");
}
}
}
// get reference proxy
// Subclasses should synchronize on the given Object if they perform any sort of extended singleton creation

View File

@ -60,7 +60,7 @@ public class DubboConfigApplicationListener
}
}
public void init() {
public synchronized void init() {
// It's expected to be notified at
// org.springframework.context.support.AbstractApplicationContext.registerListeners(),
// before loading non-lazy singleton beans. At this moment, all BeanFactoryPostProcessor have been processed,