frankvicky commented on code in PR #19914: URL: https://github.com/apache/kafka/pull/19914#discussion_r2203212279
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java: ########## @@ -178,6 +178,23 @@ public CommitRequestManager( */ @Override public NetworkClientDelegate.PollResult poll(final long currentTimeMs) { + if (coordinatorRequestManager.coordinator().isEmpty() && closing) { + CommitFailedException exception = new CommitFailedException( + "Failed to commit offsets: Coordinator unknown and consumer is closing"); + + List<NetworkClientDelegate.UnsentRequest> pendingCommits = pendingRequests.drainPendingCommits(); + + // Complete each commit request exceptionally + pendingCommits.forEach(request -> { + if (request.future() != null) { + request.future().completeExceptionally(exception); + } Review Comment: We don't need a null check here. Ref: https://github.com/apache/kafka/blob/986322dc3619fc1725012ac33eebed7db8d8cbbb/clients/src/main/java/org/apache/kafka/clients/consumer/internals/NetworkClientDelegate.java#L406 ########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java: ########## @@ -178,6 +178,23 @@ public CommitRequestManager( */ @Override public NetworkClientDelegate.PollResult poll(final long currentTimeMs) { + if (coordinatorRequestManager.coordinator().isEmpty() && closing) { + CommitFailedException exception = new CommitFailedException( + "Failed to commit offsets: Coordinator unknown and consumer is closing"); + + List<NetworkClientDelegate.UnsentRequest> pendingCommits = pendingRequests.drainPendingCommits(); Review Comment: We could inline this variable. `pendingRequests.drainPendingCommits().forEach...` -- 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