You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Matthias J. Sax (Jira)" <ji...@apache.org> on 2026/08/12 20:00:00 UTC
[jira] [Commented] (KAFKA-20922) TimestampedRangeWithHeadersQuery iterator can NPE on a null-deserialized value (KV path missing the null guard the window path has)
[ https://issues.apache.org/jira/browse/KAFKA-20922?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18104176#comment-18104176 ]
Matthias J. Sax commented on KAFKA-20922:
-----------------------------------------
It seems, this is not something we could hit in production atm though – `valueTimestampHeaders` should never be null at this place? The existing guards in window-store and session-store and fails safes only.
No objection to add the same guards, but it's not something we need to worry about for AK 4.4 release.
Btw, it seems there is two more places we should update, too:
* MeteredTimestampedKeyValueStoreWithHeadersQueryIterator.next() (line 694-695) — backs RangeQuery/TimestampedRangeQuery.
* MeteredTimestampedKeyValueStoreWithHeadersIterator.next() (line 801-802) — backs the plain (non-IQv2) range()/all()/reverseRange()/reverseAll().
> TimestampedRangeWithHeadersQuery iterator can NPE on a null-deserialized value (KV path missing the null guard the window path has)
> -----------------------------------------------------------------------------------------------------------------------------------
>
> Key: KAFKA-20922
> URL: https://issues.apache.org/jira/browse/KAFKA-20922
> Project: Kafka
> Issue Type: Bug
> Components: streams
> Reporter: Jess Jin
> Priority: Minor
>
> MeteredTimestampedKeyValueStoreWithHeadersReadOnlyRecordIterator.next() (backing TimestampedRangeWithHeadersQuery) dereferences a possibly-null ValueTimestampHeaders:
> {code:java}
> final ValueTimestampHeaders<V> valueTimestampHeaders = valueTimestampHeadersDeserializer.apply(keyValue.value);
> final Headers headers = valueTimestampHeaders.headers(); // NPE if valueTimestampHeaders == null
> {code}
> ValueTimestampHeaders.make() returns null whenever the value deserializes to null, so valueTimestampHeaders can be null and .headers() throws a bare NullPointerException.
> The window-store path (MeteredWindowStoreWithHeadersReadOnlyRecordIterator.next()) already guards this and throws a StreamsException naming the key instead. The KV path should mirror that guard.
> Found during review of PR #22975: [https://github.com/apache/kafka/pull/22975#discussion_r3738681473]
--
This message was sent by Atlassian Jira
(v8.20.10#820010)