You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by GitBox <gi...@apache.org> on 2022/12/02 23:27:01 UTC

[GitHub] [hadoop] xkrogen commented on a diff in pull request #5160: HDFS-16852 Swallow IllegalStateException in KeyProviderCache constructor

xkrogen commented on code in PR #5160:
URL: https://github.com/apache/hadoop/pull/5160#discussion_r1038622347


##########
hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/KeyProviderCache.java:
##########
@@ -68,8 +68,11 @@ public void onRemoval(
         })
         .build();
 
-    ShutdownHookManager.get().addShutdownHook(new KeyProviderCacheFinalizer(),
-        SHUTDOWN_HOOK_PRIORITY);
+    try {
+      ShutdownHookManager.get().addShutdownHook(new KeyProviderCacheFinalizer(), SHUTDOWN_HOOK_PRIORITY);
+    } catch (IllegalStateException e) {
+      LOG.warn("shutdownHook not added", e);
+    }

Review Comment:
   We should first check if a shutdown is in progress and then add a shutdown hook if not, rather than catching the exception. Like the example in `FileSystem`:
   https://github.com/apache/hadoop/blob/60e0fe87094771b3188b9b1cd4bf7acf54d40ab7/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/FileSystem.java#L3715-L3720



-- 
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: common-issues-unsubscribe@hadoop.apache.org

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


---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org