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
| Author | Chia-Chuan Yu |
| Status | Discussion |
| JIRA | KAFKA-17826 |
| Wiki | View on Apache Wiki |
| Created | 2024-10-31 |
| Last Modified | 2025-05-04 |
Explore how this KIP affects the Kafka protocol in the Protocol Explorer, or see the full KIP database.