apoorvmittal10 commented on code in PR #20290:
URL: https://github.com/apache/kafka/pull/20290#discussion_r2256984922


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ShareConsumerImpl.java:
##########
@@ -895,12 +895,14 @@ private void close(final Duration timeout, final boolean 
swallowException) {
         closeTimer.update();
 
         // Prepare shutting down the network thread
-        swallow(log, Level.ERROR, "Failed to release assignment before closing 
consumer",
-                () -> sendAcknowledgementsAndLeaveGroup(closeTimer, 
firstException), firstException);
-        swallow(log, Level.ERROR, "Failed to stop finding coordinator",
-                this::stopFindCoordinatorOnClose, firstException);
-        swallow(log, Level.ERROR, "Failed invoking acknowledgement commit 
callback",
-                () -> handleCompletedAcknowledgements(true), firstException);
+        if (applicationEventHandler != null && backgroundEventReaper != null 
&& backgroundEventQueue != null) {
+            swallow(log, Level.ERROR, "Failed to release assignment before 
closing consumer",
+                    () -> sendAcknowledgementsAndLeaveGroup(closeTimer, 
firstException), firstException);
+            swallow(log, Level.ERROR, "Failed to stop finding coordinator",
+                    this::stopFindCoordinatorOnClose, firstException);

Review Comment:
   This close is only dependent on `applicationEventHandler` hence do not 
require all 3 to be non-null i.e. `applicationEventHandler != null && 
backgroundEventReaper != null && backgroundEventQueue != null`. Please simplify 
for `stopFindCoordinatorOnClose`.



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