diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java index 4cea47c399238..32bc9b7c90d19 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransportStopTransformAction.java @@ -141,14 +141,16 @@ static Tuple, Set> findTasksWithoutConfig(ClusterState state Set taskIds = new HashSet<>(); Set executorNodes = new HashSet<>(); - Predicate> taskMatcher = Strings.isAllOrWildcard(new String[] { transformId }) ? t -> true : t -> { - TransformTaskParams transformParams = (TransformTaskParams) t.getParams(); - return Regex.simpleMatch(transformId, transformParams.getId()); - }; - - for (PersistentTasksCustomMetaData.PersistentTask pTask : tasks.findTasks(TransformField.TASK_NAME, taskMatcher)) { - executorNodes.add(pTask.getExecutorNode()); - taskIds.add(pTask.getId()); + if (tasks != null) { + Predicate> taskMatcher = Strings.isAllOrWildcard(new String[] { transformId }) ? t -> true : t -> { + TransformTaskParams transformParams = (TransformTaskParams) t.getParams(); + return Regex.simpleMatch(transformId, transformParams.getId()); + }; + + for (PersistentTasksCustomMetaData.PersistentTask pTask : tasks.findTasks(TransformField.TASK_NAME, taskMatcher)) { + executorNodes.add(pTask.getExecutorNode()); + taskIds.add(pTask.getId()); + } } return new Tuple<>(taskIds, executorNodes);