From 7ab6a7e83ac11d2aecdd6591fe8ef5bc89d74092 Mon Sep 17 00:00:00 2001 From: David Roberts Date: Mon, 19 Jun 2017 16:24:10 +0100 Subject: [PATCH] [ML] Fix NullPointerException when deleting a job with state "opening" (elastic/x-pack-elasticsearch#1769) relates elastic/x-pack-elasticsearch#1768 Original commit: elastic/x-pack-elasticsearch@ae1f431316588c95dbf24f67a4d75e9f05dde6b3 --- .../src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java b/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java index 957bc3d99a5..e4f4b4e87bc 100644 --- a/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java +++ b/plugin/src/main/java/org/elasticsearch/xpack/ml/MlMetadata.java @@ -365,8 +365,9 @@ public class MlMetadata implements MetaData.Custom { if (allowDeleteOpenJob == false) { PersistentTask jobTask = getJobTask(jobId, tasks); if (jobTask != null) { + JobTaskStatus jobTaskStatus = (JobTaskStatus) jobTask.getStatus(); throw ExceptionsHelper.conflictStatusException("Cannot delete job [" + jobId + "] because the job is " - + ((JobTaskStatus) jobTask.getStatus()).getState()); + + ((jobTaskStatus == null) ? JobState.OPENING : jobTaskStatus.getState())); } } Job.Builder jobBuilder = new Job.Builder(job);