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


##########
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:
   Thanks @apoorvmittal10 and @lianetm for the review.
   I have added the null checks inside each function now to make it clearer and 
ensure we do not face this issue again if we re-use the function later.



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