philipnee commented on code in PR #15525:
URL: https://github.com/apache/kafka/pull/15525#discussion_r1539524047


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java:
##########
@@ -1141,21 +1141,27 @@ private Map<TopicPartition, Long> 
beginningOrEndOffset(Collection<TopicPartition
             if (partitions.isEmpty()) {
                 return Collections.emptyMap();
             }
+
             Map<TopicPartition, Long> timestampToSearch = partitions
                 .stream()
                 .collect(Collectors.toMap(Function.identity(), tp -> 
timestamp));
             Timer timer = time.timer(timeout);
             ListOffsetsEvent listOffsetsEvent = new ListOffsetsEvent(
                 timestampToSearch,
-                false,
                 timer);
-            Map<TopicPartition, OffsetAndTimestamp> offsetAndTimestampMap = 
applicationEventHandler.addAndGet(
+
+            // shortcut the request if the timeout is zero.
+            if (timeout.isZero()) {

Review Comment:
   Hey @lucasbru - It seems like one of the handlers would also update the 
subscription state upon completion. See the snippet below:
   ```
                   public void onSuccess(ListOffsetResult value) {
                       synchronized (future) {
                           result.fetchedOffsets.putAll(value.fetchedOffsets);
                           
remainingToSearch.keySet().retainAll(value.partitionsToRetry);
   
                           
offsetFetcherUtils.updateSubscriptionState(value.fetchedOffsets, 
isolationLevel);
                       }
                   }
   
   ```
   
   I think addAndGet seems to be sufficient to handle such logic so I'll revert 
this code.



-- 
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

Reply via email to