mvanhorn commented on code in PR #21716:
URL: https://github.com/apache/kafka/pull/21716#discussion_r2921931604


##########
streams/src/main/java/org/apache/kafka/streams/processor/internals/metrics/StreamsMetricsImpl.java:
##########
@@ -366,10 +366,16 @@ public final void removeAllThreadLevelMetrics(final 
String threadId) {
     }
 
     public void removeMetric(final MetricName metricName) {
+        if (metricName == null) {

Review Comment:
   Good question. Looking at the callers, `DefaultStateUpdater.clear()` pops 
from `allMetricNames` which is populated by `metricsRegistry.metricName()` - so 
null shouldn't occur in the normal path. The JIRA reports an NPE during 
concurrent topology changes, which suggests a race between metrics 
initialization and cleanup. However, I haven't been able to trace the exact 
sequence where `metricName()` returns null.
   
   This is a defensive guard rather than a root-cause fix. If you'd prefer a 
more targeted approach - like tracing the actual race condition or adding a log 
warning instead of silently returning - I'm happy to adjust.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to