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


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java:
##########
@@ -269,22 +270,40 @@ void cleanup() {
      * completed in time.
      */
     // Visible for testing
-    void maybeAutoCommitAndLeaveGroup(final Timer timer) {
+    void maybeAutocommitOnClose(final Timer timer) {
         if (!requestManagers.coordinatorRequestManager.isPresent())
             return;
 
+        if (!requestManagers.commitRequestManager.isPresent()) {
+            log.error("Expecting a CommitRequestManager but the object was 
never initialized. Shutting down.");
+            return;
+        }
+
+        if (!requestManagers.commitRequestManager.get().autoCommitEnabled()) {
+            return;
+        }
+
         ensureCoordinatorReady(timer);
-        List<NetworkClientDelegate.UnsentRequest> tasks = closingRequests();
-        networkClientDelegate.addAll(tasks);
+        Optional<NetworkClientDelegate.UnsentRequest> autocommit = 
requestManagers.commitRequestManager.get().maybeCreateAutoCommitRequest();
+        if (!autocommit.isPresent()) {
+            return;
+        }
+
+        List<NetworkClientDelegate.UnsentRequest> autocommitRequest = 
Collections.singletonList(autocommit.get());
+        networkClientDelegate.addAll(autocommitRequest);
         do {
             long currentTimeMs = timer.currentTimeMs();
             ensureCoordinatorReady(timer);
             networkClientDelegate.poll(timer.remainingMs(), currentTimeMs);
-        } while (timer.notExpired() && !tasks.stream().allMatch(v -> 
v.future().isDone()));
+        } while (timer.notExpired() && 
!autocommitRequest.get(0).future().isDone());
+    }
+
+    void maybeLeaveGroup(final Timer timer) {
+        // TODO: Leave group upon closing the consumer

Review Comment:
   Can I follow up with a subsequent ticket to address this?



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to