From 8be3077a589e8792e0ea799bf74e3885c24bbd92 Mon Sep 17 00:00:00 2001 From: Jeff Xiang Date: Wed, 30 Oct 2024 14:28:54 -0400 Subject: [PATCH] Add null check to prevent initialization NPE for byteOutMetric in PscWriter --- .../java/com/pinterest/flink/connector/psc/sink/PscWriter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/psc-flink/src/main/java/com/pinterest/flink/connector/psc/sink/PscWriter.java b/psc-flink/src/main/java/com/pinterest/flink/connector/psc/sink/PscWriter.java index 03a6e7d..eaf7394 100644 --- a/psc-flink/src/main/java/com/pinterest/flink/connector/psc/sink/PscWriter.java +++ b/psc-flink/src/main/java/com/pinterest/flink/connector/psc/sink/PscWriter.java @@ -430,6 +430,9 @@ private void registerMetricSync() { if (closed) { return; } + if (byteOutMetric == null || byteOutMetric.metricValue() == null) { + return; + } long outgoingBytesUntilNow = ((Number) byteOutMetric.metricValue()).longValue(); long outgoingBytesSinceLastUpdate = outgoingBytesUntilNow - latestOutgoingByteTotal;