From 0995ac308488cb96f7e18545b1d061dde02aca2c Mon Sep 17 00:00:00 2001 From: liufeiyu Date: Mon, 3 Jul 2023 20:07:23 +0800 Subject: [PATCH] =?UTF-8?q?fix=20#12620=20=E4=BF=AE=E5=A4=8Dspring=20dubbo?= =?UTF-8?q?=20=E5=90=AF=E5=8A=A8=E8=BF=87=E7=A8=8B=E4=B8=AD=E6=AD=BB?= =?UTF-8?q?=E9=94=81=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spring/context/DubboDeployApplicationListener.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java index 72cfa1b3877a..a189bcc8552e 100644 --- a/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java +++ b/dubbo-config/dubbo-config-spring/src/main/java/org/apache/dubbo/config/spring/context/DubboDeployApplicationListener.java @@ -30,6 +30,7 @@ import org.apache.dubbo.rpc.model.ModuleModel; import org.springframework.beans.BeansException; +import org.springframework.beans.factory.support.DefaultSingletonBeanRegistry; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationListener; @@ -146,8 +147,12 @@ public void onApplicationEvent(ApplicationContextEvent event) { private void onContextRefreshedEvent(ContextRefreshedEvent event) { ModuleDeployer deployer = moduleModel.getDeployer(); Assert.notNull(deployer, "Module deployer is null"); + Object singletonMutex = ((DefaultSingletonBeanRegistry) applicationContext.getAutowireCapableBeanFactory()).getSingletonMutex(); // start module - Future future = deployer.start(); + Future future = null; + synchronized (singletonMutex) { + future = deployer.start(); + } // if the module does not start in background, await finish if (!deployer.isBackground()) { @@ -177,7 +182,7 @@ private void onContextClosedEvent(ContextClosedEvent event) { @Override public int getOrder() { - return LOWEST_PRECEDENCE; + return LOWEST_PRECEDENCE - 100; } }