You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "xijiu (via GitHub)" <gi...@apache.org> on 2025/05/02 11:52:51 UTC

Re: [PR] KAFKA-19205: inconsistent result of beginningOffsets/endoffset between classic and async consumer with 0 timeout [kafka]

xijiu commented on code in PR #19578:
URL: https://github.com/apache/kafka/pull/19578#discussion_r2071504565


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:
##########
@@ -1306,7 +1306,10 @@ private Map<TopicPartition, Long> beginningOrEndOffset(Collection<TopicPartition
             // and throw timeout exception if it cannot complete in time.
             if (timeout.isZero()) {
                 applicationEventHandler.add(listOffsetsEvent);
-                return listOffsetsEvent.emptyResults();
+                // It is used to align with classic consumer.
+                // When the "timeout == 0", the classic consumer will return an empty map.
+                // Therefore, the AsyncKafkaConsumer needs to be consistent with it.
+                return new HashMap<>();

Review Comment:
   @lianetm  Thanks very much for code review, and I have fixed it, PTAL



-- 
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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org