mvanhorn opened a new pull request, #21716:
URL: https://github.com/apache/kafka/pull/21716

   ## Summary
   
   `StreamsMetricsImpl.removeMetric()` and `removeStoreLevelMetric()` throw 
`NullPointerException` when called with a null `MetricName` during topology 
startup. This can happen when metrics are removed before being fully 
initialized, particularly during concurrent topology changes.
   
   This PR adds null guards to both methods so they return early instead of 
propagating the NPE.
   
   ## Changes
   
   - `StreamsMetricsImpl.removeMetric()`: Added null check for `metricName` 
parameter
   - `StreamsMetricsImpl.removeStoreLevelMetric()`: Added null check for 
`metricName` parameter
   - Added unit tests for both null-guard paths
   
   ## Test Plan
   
   - [x] Added `testRemoveMetricWithNullNameDoesNotThrow` test
   - [x] Added `testRemoveStoreLevelMetricWithNullNameDoesNotThrow` test
   
   This contribution was developed with AI assistance (Claude Code).


-- 
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