[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@ae1f431316
This commit is contained in:
David Roberts 2017-06-19 16:24:10 +01:00 committed by GitHub
parent c1685c70ea
commit 7ab6a7e83a
1 changed files with 2 additions and 1 deletions

View File

@ -365,8 +365,9 @@ public class MlMetadata implements MetaData.Custom {
if (allowDeleteOpenJob == false) { if (allowDeleteOpenJob == false) {
PersistentTask<?> jobTask = getJobTask(jobId, tasks); PersistentTask<?> jobTask = getJobTask(jobId, tasks);
if (jobTask != null) { if (jobTask != null) {
JobTaskStatus jobTaskStatus = (JobTaskStatus) jobTask.getStatus();
throw ExceptionsHelper.conflictStatusException("Cannot delete job [" + jobId + "] because the job is " 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); Job.Builder jobBuilder = new Job.Builder(job);