You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/09/16 11:06:42 UTC

[GitHub] [dubbo] zrlw commented on a change in pull request #8824: [3.0] Refactor application/module deploy processing and events

zrlw commented on a change in pull request #8824:
URL: https://github.com/apache/dubbo/pull/8824#discussion_r710014603



##########
File path: dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/DubboShutdownHook.java
##########
@@ -81,7 +85,11 @@ public void register() {
      */
     public void unregister() {
         if (registered.compareAndSet(true, false)) {
-            Runtime.getRuntime().removeShutdownHook(this);
+            try {
+                Runtime.getRuntime().removeShutdownHook(this);

Review comment:
       ShutdownHookCallbacks.callback() will be called at Runtime.getRuntime().removeShutdownHook(this):
   ```
   ##[error]Exception in thread "DubboShutdownHook" java.lang.RuntimeException: java.lang.IllegalStateException: Shutdown in progress
    	at org.apache.dubbo.common.function.ThrowableAction.execute(ThrowableAction.java:48)
    	at org.apache.dubbo.common.lang.ShutdownHookCallbacks.lambda$callback$0(ShutdownHookCallbacks.java:72)
    	at java.lang.Iterable.forEach(Iterable.java:75)
    	at org.apache.dubbo.common.lang.ShutdownHookCallbacks.callback(ShutdownHookCallbacks.java:72)
    	at org.apache.dubbo.config.DubboShutdownHook.callback(DubboShutdownHook.java:89)
   ```
   we might add try-catch in ShutdownHookCallbacks callback() method like this, otherwise the callbacks in getCallbacks() after the callback which throw the exception will lost running opptunity:
   ```
       private static final Logger logger = LoggerFactory.getLogger(ShutdownHookCallbacks.class);
       public void callback() {
           getCallbacks().forEach(callback -> {
               try {
                   execute(callback::callback);
               } catch (Exception e) {
                   logger.warn("callback exception.", e);
               }
           });
       }
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org