From 51b56ba4361591c7a38cbc68f958d70847b0547e Mon Sep 17 00:00:00 2001 From: David Rieber Date: Sun, 17 Feb 2019 18:04:56 -0800 Subject: [PATCH] Fix NPE in ComputationState constructor introduced by PR/7846. The root cause was assuming an empty transformUserNameToStateFamily map was passed, when instead null was passed. --- .../runners/dataflow/worker/StreamingDataflowWorker.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java b/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java index ea8bc9d089f8..a6e8df6d2b0b 100644 --- a/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java +++ b/runners/google-cloud-dataflow-java/worker/src/main/java/org/apache/beam/runners/dataflow/worker/StreamingDataflowWorker.java @@ -1540,7 +1540,8 @@ private void getConfigFromWindmill(String computation) { for (Windmill.GetConfigResponse.ComputationConfigMapEntry computationConfig : response.getComputationConfigMapList()) { Map transformUserNameToStateFamily = - transformUserNameToStateFamilyByComputationId.get(computationConfig.getComputationId()); + transformUserNameToStateFamilyByComputationId.computeIfAbsent( + computationConfig.getComputationId(), k -> new HashMap<>()); for (Windmill.ComputationConfig.TransformUserNameToStateFamilyEntry entry : computationConfig.getComputationConfig().getTransformUserNameToStateFamilyList()) { transformUserNameToStateFamily.put(entry.getTransformUserName(), entry.getStateFamily()); @@ -1949,7 +1950,10 @@ public ComputationState( this.computationId = computationId; this.mapTask = mapTask; this.executor = executor; - this.transformUserNameToStateFamily = ImmutableMap.copyOf(transformUserNameToStateFamily); + this.transformUserNameToStateFamily = + transformUserNameToStateFamily != null + ? ImmutableMap.copyOf(transformUserNameToStateFamily) + : ImmutableMap.of(); Preconditions.checkNotNull(mapTask.getStageName()); Preconditions.checkNotNull(mapTask.getSystemName()); }