Skip to content

Commit

Permalink
fix #12620 修复spring dubbo启动过程中死锁问题
Browse files Browse the repository at this point in the history
  • Loading branch information
liufeiyu1002 committed Jul 5, 2023
1 parent dce7b87 commit 405628b
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -177,7 +182,7 @@ private void onContextClosedEvent(ContextClosedEvent event) {

@Override
public int getOrder() {
return LOWEST_PRECEDENCE;
return LOWEST_PRECEDENCE - 100;
}

}

0 comments on commit 405628b

Please sign in to comment.