Merge branch 'master' into 2.7.6-release

This commit is contained in:
ken.lj 2020-03-03 12:11:08 +08:00
commit 40e8bdd4e8
2 changed files with 7 additions and 9 deletions

View File

@ -52,7 +52,7 @@ public class DubboShutdownHook extends Thread {
/**
* Has it already been destroyed or not?
*/
private final AtomicBoolean destroyed = new AtomicBoolean(false);
private static final AtomicBoolean destroyed = new AtomicBoolean(false);
private final EventDispatcher eventDispatcher = EventDispatcher.getDefaultExtension();
@ -111,17 +111,15 @@ public class DubboShutdownHook extends Thread {
* Destroy all the resources, including registries and protocols.
*/
public void doDestroy() {
if (!destroyed.compareAndSet(false, true)) {
return;
}
// dispatch the DubboDestroyedEvent @since 2.7.5
dispatch(new DubboServiceDestroyedEvent(this));
}
public static void destroyAll() {
AbstractRegistryFactory.destroyAll();
destroyProtocols();
if (destroyed.compareAndSet(false, true)) {
AbstractRegistryFactory.destroyAll();
destroyProtocols();
}
}
private void dispatch(Event event) {

View File

@ -1033,11 +1033,11 @@ public class DubboBootstrap extends GenericEventListener {
}
public void destroy() {
// for compatibility purpose
DubboShutdownHook.destroyAll();
if (started.compareAndSet(true, false)
&& destroyed.compareAndSet(false, true)) {
// for compatibility purpose
DubboShutdownHook.destroyAll();
unregisterServiceInstance();
unexportMetadataService();