lucasbru commented on code in PR #14937: URL: https://github.com/apache/kafka/pull/14937#discussion_r1420557352
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java: ########## @@ -178,27 +171,11 @@ static void runAtClose(final Collection<Optional<? extends RequestManager>> requ final NetworkClientDelegate networkClientDelegate, final Timer timer) { Review Comment: Seems timer is now completely unused. ########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java: ########## @@ -317,7 +326,7 @@ private void process(final GroupMetadataUpdateEvent event) { networkClientDelegateSupplier); final Supplier<ApplicationEventProcessor> applicationEventProcessorSupplier = ApplicationEventProcessor.supplier(logContext, metadata, - applicationEventQueue, + applicationEventQueue, Review Comment: indentation ########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java: ########## @@ -273,80 +250,28 @@ private void closeInternal(final Duration timeout) { } } + private void sendUnsentRequests(final Timer timer) { + // Poll to ensure that request has been written to the socket. Wait until either the timer has expired or until + // all requests have received a response. + while (!networkClientDelegate.unsentRequests().isEmpty() && timer.notExpired()) { Review Comment: Closing with timeout 0 would mean we don't send any closing requests, right? I think we should `poll` nevertheless, so we should check the timer at the end. I think if we'd use the normal poll loop as long as `timeout > 0`, this function may not need to check the timer anyway, since it's only used if the time ran out and there are still unsent requests. ########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/AsyncKafkaConsumer.java: ########## @@ -469,7 +481,7 @@ private void process(final GroupMetadataUpdateEvent event) { Supplier<ApplicationEventProcessor> applicationEventProcessorSupplier = ApplicationEventProcessor.supplier( logContext, metadata, - applicationEventQueue, + applicationEventQueue, Review Comment: indentation ########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/FetchRequestManager.java: ########## @@ -82,6 +82,7 @@ public PollResult poll(long currentTimeMs) { */ @Override public PollResult pollOnClose() { + // TODO: move the logic to poll to handle signal close Review Comment: Yes, using the normal poll loop sounds like a good idea. We should still probably `sendUnsentRequests` once when the timeout has passed. -- 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