conduktor.io ↗

KIP-1140 — Avoid to return null value in Map from public api of consumer

Discussion Consumer

Changes `KafkaConsumer.offsetsForTimes()` to return `Optional<OffsetAndTimestamp>` instead of `OffsetAndTimestamp` (nullable) for partitions with no matching timestamp, removing null values from the returned map. Returning null values in a `Map` violates the principle of least surprise and causes `NullPointerException` when callers iterate the map without null checks.

Details

AuthorChia-Chuan Yu
StatusDiscussion
JIRAKAFKA-17826
WikiView on Apache Wiki
Created2024-10-31
Last Modified2025-05-04
Explore how this KIP affects the Kafka protocol in the Protocol Explorer, or see the full KIP database.