Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deadlock when starting #12659

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 HIGHEST_PRECEDENCE;
}

}