Skip to content
Merged
Show file tree
Hide file tree
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 @@ -55,13 +55,13 @@ public void run() {
if (logger.isInfoEnabled()) {
logger.info("Run shutdown hook now.");
}
destroyAll();
doDestroy();
}

/**
* Destroy all the resources, including registries and protocols.
*/
public void destroyAll() {
public void doDestroy() {
if (!destroyed.compareAndSet(false, true)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class SpringExtensionFactory implements ExtensionFactory {

public static void addApplicationContext(ApplicationContext context) {
contexts.add(context);
Runtime.getRuntime().removeShutdownHook(DubboShutdownHook.getDubboShutdownHook());
BeanFactoryUtils.addApplicationListener(context, shutdownHookListener);
}

Expand Down Expand Up @@ -105,11 +106,8 @@ private static class ShutdownHookListener implements ApplicationListener {
@Override
public void onApplicationEvent(ApplicationEvent event) {
if (event instanceof ContextClosedEvent) {
// we call it anyway since dubbo shutdown hook make sure its destroyAll() is re-entrant.
// pls. note we should not remove dubbo shutdown hook when spring framework is present, this is because
// its shutdown hook may not be installed.
DubboShutdownHook shutdownHook = DubboShutdownHook.getDubboShutdownHook();
shutdownHook.destroyAll();
shutdownHook.doDestroy();
}
}
}
Expand Down