Skip to content

Commit

Permalink
enhance shutdown hook in spring (#3008)
Browse files Browse the repository at this point in the history
  • Loading branch information
beiwei30 authored and zonghaishang committed Dec 18, 2018
1 parent e4acdf7 commit df219f3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public void doDestroy() {
if (!destroyed.compareAndSet(false, true)) {
return;
}
// unregister the shutdownHook
unregister();
// destroy all the registries
AbstractRegistryFactory.destroyAll();
// destroy all the protocols
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.event.ContextClosedEvent;

import java.util.Set;
Expand All @@ -44,7 +45,10 @@ public class SpringExtensionFactory implements ExtensionFactory {

public static void addApplicationContext(ApplicationContext context) {
contexts.add(context);
DubboShutdownHook.getDubboShutdownHook().unregister();
if (context instanceof ConfigurableApplicationContext) {
((ConfigurableApplicationContext) context).registerShutdownHook();
DubboShutdownHook.getDubboShutdownHook().unregister();
}
BeanFactoryUtils.addApplicationListener(context, shutdownHookListener);
}

Expand Down

0 comments on commit df219f3

Please sign in to comment.