[ASTERIXDB-2120][HYR][RT] Avoid NPE in case of unknown job

Change-Id: I77267aeaf1a0f6498146fe6f0b5777eb6ba47054
Reviewed-on: https://asterix-gerrit.ics.uci.edu/2049
Reviewed-by: Murtadha Hubail <mhubail@apache.org>
Integration-Tests: Michael Blow <mblow@apache.org>
Tested-by: Michael Blow <mblow@apache.org>
Contrib: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobletCleanupNotificationWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobletCleanupNotificationWork.java
index 5bf721b..337e88f 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobletCleanupNotificationWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/JobletCleanupNotificationWork.java
@@ -51,12 +51,14 @@
     public void runWork() {
         IJobManager jobManager = ccs.getJobManager();
         final JobRun run = jobManager.get(jobId);
+        if (run == null) {
+            LOGGER.log(Level.WARNING, () -> "ignoring unknown job " + jobId + " on notification from " + nodeId);
+            return;
+        }
         Set<String> cleanupPendingNodes = run.getCleanupPendingNodeIds();
         if (!cleanupPendingNodes.remove(nodeId)) {
-            if (LOGGER.isLoggable(Level.WARNING)) {
-                LOGGER.warning(
-                        nodeId + " not in pending cleanup nodes set: " + cleanupPendingNodes + " for Job: " + jobId);
-            }
+            LOGGER.log(Level.WARNING, () -> nodeId + " not in pending cleanup nodes set: " + cleanupPendingNodes +
+                    " for job " + jobId);
             return;
         }
         INodeManager nodeManager = ccs.getNodeManager();