squah-confluent commented on code in PR #20451: URL: https://github.com/apache/kafka/pull/20451#discussion_r2316589708
########## clients/src/main/java/org/apache/kafka/clients/consumer/OffsetAndMetadata.java: ########## @@ -99,28 +99,35 @@ public Optional<Integer> leaderEpoch() { return Optional.of(leaderEpoch); } + /** + * Normalizes leader epoch values for comparison and hashing. + * Both null and negative values are considered equivalent (representing absent/unknown epoch). + */ + private Integer normalizeLeaderEpoch(Integer leaderEpoch) { + return (leaderEpoch == null || leaderEpoch < 0) ? null : leaderEpoch; + } + Review Comment: Can we use the existing `leaderEpoch` method to normalize the `leaderEpoch`? It already maps `null` and negatives to `Optional.empty()`. ########## clients/src/main/java/org/apache/kafka/clients/consumer/OffsetAndMetadata.java: ########## @@ -99,28 +99,35 @@ public Optional<Integer> leaderEpoch() { return Optional.of(leaderEpoch); } + /** + * Normalizes leader epoch values for comparison and hashing. + * Both null and negative values are considered equivalent (representing absent/unknown epoch). + */ + private Integer normalizeLeaderEpoch(Integer leaderEpoch) { Review Comment: nit: Since this method doesn't use any instance members we can make it `static` or remove the `leaderEpoch` parameter. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org