From 47aac991ec7a0950f3cadbbac891003eee883a7f Mon Sep 17 00:00:00 2001 From: Nishant Date: Fri, 4 Sep 2015 21:39:36 +0530 Subject: [PATCH] add null check for task context. make variable final --- .../indexing/overlord/ForkingTaskRunner.java | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/indexing-service/src/main/java/io/druid/indexing/overlord/ForkingTaskRunner.java b/indexing-service/src/main/java/io/druid/indexing/overlord/ForkingTaskRunner.java index e606d345f75..6d249f4284d 100644 --- a/indexing-service/src/main/java/io/druid/indexing/overlord/ForkingTaskRunner.java +++ b/indexing-service/src/main/java/io/druid/indexing/overlord/ForkingTaskRunner.java @@ -215,15 +215,18 @@ public class ForkingTaskRunner implements TaskRunner, TaskLogStreamer } // Override task specific properties - for (String propName : task.getContext().keySet()) { - if (propName.startsWith(CHILD_PROPERTY_PREFIX)) { - command.add( - String.format( - "-D%s=%s", - propName.substring(CHILD_PROPERTY_PREFIX.length()), - task.getContextValue(propName) - ) - ); + final Map context = task.getContext(); + if (context != null) { + for (String propName : context.keySet()) { + if (propName.startsWith(CHILD_PROPERTY_PREFIX)) { + command.add( + String.format( + "-D%s=%s", + propName.substring(CHILD_PROPERTY_PREFIX.length()), + task.getContextValue(propName) + ) + ); + } } }