Hi, It looks like you found a bug. Feel free to open a pull request if you want to fix it, or at least open a Jira to report the issue.
Thanks, Mickael On Thu, Nov 6, 2025 at 12:38 AM dhidah riadh <[email protected]> wrote: > > Hi Kafka community, > > I’m running MirrorMaker 2 (Kafka Connect, Kafka 4.1.0) and noticed a > recurring NullPointerException in MirrorSourceMetrics during high load: > exactly here : > https://github.com/apache/kafka/blob/61e63f12635ad6ff50c5a4e54d51d725ae82d11a/connect/mirror/src/main/java/org/apache/kafka/connect/mirror/MirrorSourceMetrics.java#L125 > > > java.lang.NullPointerException: Cannot read field "recordAgeSensor" because > the return value of "java.util.Map.get(Object)" is null > > After checking the code, it seems the problem happens when the metrics map > doesn’t contain an entry for the partition being processed , a simple > NULL check > would completely prevent this crash. > > Looks like this usually occurs when a *rebalance or internal reload* > happens while MirrorMaker is under high load. When that happens, the > metrics map is refreshed, and the task crashes with this NPE. > Kafka Connect treats it as *FATAL*, which *kills the entire task*, and > replication for that flow stops until the task is *manually restarted*. > > The fix looks trivial, that's why I was wondering *why this null check > isn’t already in place !!* > > Maybe I’m missing something, or it’s expected only in specific > configurations? > > Right now, I’ve implemented a local override of the metrics class with a > metrics NULL check, and it works fine. > I just want to confirm whether this behavior is known or if my MirrorMaker > setup could be misconfigured..... > > *Proposed change:* a null check for the metric to avoid this, or catching > the exception . > > > Thanks for any insight on this, > Dh.Riadh
