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-unsubscr...@hadoop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org