You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dipesh Chandra Maurya (Jira)" <ji...@apache.org> on 2026/07/08 09:38:00 UTC

[jira] [Comment Edited] (SPARK-55271) NullPointerException in Kafka Micro-Batch Streaming Progress Reporting

    [ https://issues.apache.org/jira/browse/SPARK-55271?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18094546#comment-18094546 ] 

Dipesh Chandra Maurya edited comment on SPARK-55271 at 7/8/26 9:37 AM:
-----------------------------------------------------------------------

[~sebastian_eckweiler] i have raised PR for spark-4.1, i can raise for 4.2.0 and 4.1.3 too.


was (Author: JIRAUSER312276):
[~sebastian_eckweiler] i can raise PR for spark-4.1, i can raise for 4.2.0 and 4.1.3 too.

> NullPointerException in Kafka Micro-Batch Streaming Progress Reporting
> ----------------------------------------------------------------------
>
>                 Key: SPARK-55271
>                 URL: https://issues.apache.org/jira/browse/SPARK-55271
>             Project: Spark
>          Issue Type: Bug
>          Components: Structured Streaming
>    Affects Versions: 4.1.1
>            Reporter: Dipesh Chandra Maurya
>            Priority: Critical
>              Labels: pull-request-available
>
> h3. Root Cause
> The error originates in {{KafkaMicroBatchStream.metrics()}} at line 520, where the code attempts to call {{.get()}} on a Scala {{Option}} that contains {{{}null{}}}, then immediately invokes {{.map()}} on the null result. This violates Scala's Option contract and causes the NullPointerException.
> h3. Error Flow
>  # The streaming query completes a micro-batch trigger
>  # Progress reporting attempts to extract source metrics via {{ProgressContext.extractSourceProgress()}}
>  # The KafkaMicroBatchStream is queried for its metrics
>  # An unsafe {{.get()}} call on an empty or null Option returns null
>  # Attempting to call {{.map()}} on the null value throws NullPointerException
> h3. Impact
>  * The streaming query crashes and stops processing
>  * Progress information cannot be generated for the current batch
>  * The failure occurs during the finishTrigger phase, after batch processing completes
> h3. Technical Details
>  * {*}Component{*}: Spark Structured Streaming with Kafka source
>  * {*}Class{*}: {{org.apache.spark.sql.kafka010.KafkaMicroBatchStream}}
>  * {*}Method{*}: {{metrics()}} at line 520
>  * {*}Trigger Type{*}: ProcessingTime (micro-batch mode)
> h3. Likely Causes
>  * Missing or unavailable Kafka metrics configuration
>  * Empty/uninitialized metrics collection in the Kafka source
>  * Race condition where metrics are accessed before initialization
>  * Incompatibility between Spark and Kafka connector versions



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org