[NO ISSUE] Avoid NPE logging shutdown hooks if shutdown already in progress

Change-Id: Id7102a975bd6e2d653198067bb5b5e7573ded7e7
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2962
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Sonar-Qube: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java
index f9d9b1b..e2ae73a 100644
--- a/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java
+++ b/hyracks-fullstack/hyracks/hyracks-util/src/main/java/org/apache/hyracks/util/ExitUtil.java
@@ -161,9 +161,12 @@
                 Field hooksField = clazz.getDeclaredField("hooks");
                 hooksField.setAccessible(true);
                 IdentityHashMap hooks = (IdentityHashMap) hooksField.get(null);
-                LOGGER.info("the following ({}) shutdown hooks have been registered: {}", hooks::size, hooks::toString);
+                if (hooks != null) {
+                    LOGGER.info("the following ({}) shutdown hooks have been registered: {}", hooks::size,
+                            hooks::toString);
+                }
             } catch (Exception e) {
-                LOGGER.warn("ignoring exception trying to determine number of shutdown hooks", e);
+                LOGGER.debug("ignoring exception trying to log shutdown hooks", e);
             }
         }
     }