You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by al...@apache.org on 2023/07/14 01:52:16 UTC
[dubbo] branch 3.2 updated: Fix deadlock when starting (#12659)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.2
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.2 by this push:
new 1c5265073b Fix deadlock when starting (#12659)
1c5265073b is described below
commit 1c5265073bb55d7a697438a2bae944377fb89343
Author: liufeiyu1002 <32...@users.noreply.github.com>
AuthorDate: Fri Jul 14 09:52:11 2023 +0800
Fix deadlock when starting (#12659)
---
.../config/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 72cfa1b387..85bb0b6708 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.ModelConstants;
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 class DubboDeployApplicationListener implements ApplicationListener<Appli
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 @@ public class DubboDeployApplicationListener implements ApplicationListener<Appli
@Override
public int getOrder() {
- return LOWEST_PRECEDENCE;
+ return HIGHEST_PRECEDENCE;
}
}