Skip to content

Commit

Permalink
Remove unregister of ShutdownHook. fix #14429
Browse files Browse the repository at this point in the history
When we register DubboShutdownHook, actions-on-exit are expected. So we should not disable the Hook.
  • Loading branch information
Chenjp committed Jul 15, 2024
1 parent f224fc5 commit 5a1ba46
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -158,27 +158,6 @@ public void register() {
}
}

/**
* Unregister the ShutdownHook
*/
public void unregister() {
if (!ignoreListenShutdownHook && registered.compareAndSet(true, false)) {
if (this.isAlive()) {
// DubboShutdownHook thread is running
return;
}
try {
Runtime.getRuntime().removeShutdownHook(this);
} catch (IllegalStateException e) {
logger.warn(
CONFIG_FAILED_SHUTDOWN_HOOK, "", "", "unregister shutdown hook failed: " + e.getMessage(), e);
} catch (Exception e) {
logger.warn(
CONFIG_FAILED_SHUTDOWN_HOOK, "", "", "unregister shutdown hook failed: " + e.getMessage(), e);
}
}
}

public boolean getRegistered() {
return registered.get();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,6 @@ private <T> ExtensionLoader<T> getExtensionLoader(Class<T> type) {
return applicationModel.getExtensionLoader(type);
}

private void unRegisterShutdownHook() {
dubboShutdownHook.unregister();
}

/**
* Close registration of instance for pure Consumer process by setting registerConsumer to 'false'
* by default is true.
Expand Down Expand Up @@ -1060,7 +1056,6 @@ public void preDestroy() {

unexportMetricsService();

unRegisterShutdownHook();
if (asyncMetadataFuture != null) {
asyncMetadataFuture.cancel(true);
}
Expand Down

0 comments on commit 5a1ba46

Please sign in to comment.