From 51134d9738681c3d35455a9c8818e45f766a5b4e Mon Sep 17 00:00:00 2001 From: Hendrik Muhs Date: Mon, 20 Jan 2020 13:52:19 +0100 Subject: [PATCH] check custom meta data to avoid NPE (#51163) check custom meta data to avoid NPE, fixes a problem introduced in #51072 fixes #51153 --- .../action/TransportStopTransformAction.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) 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 ab7c001b6e30d..98c45e1118657 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);