diff --git a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowMetrics.java b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowMetrics.java index e8e2f6c44c73..eba3448310c9 100644 --- a/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowMetrics.java +++ b/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowMetrics.java @@ -209,7 +209,14 @@ private BoundedTrieResult getBoundedTrieValue(MetricUpdate metricUpdate) { if (metricUpdate.getTrie() == null) { return BoundedTrieResult.empty(); } - BoundedTrie bTrie = (BoundedTrie) metricUpdate.getTrie(); + BoundedTrie bTrie; + try { + bTrie = (BoundedTrie) metricUpdate.getTrie(); + } catch (ClassCastException cce) { + LOG.warn( + "Failed to retrieve BoundedTrie metrics from result. Returning empty result.", cce); + return BoundedTrieResult.empty(); + } BoundedTrieData trieData = BoundedTrieData.fromProto(bTrie); return BoundedTrieResult.create(trieData.extractResult().getResult()); }