lianetm commented on code in PR #15640:
URL: https://github.com/apache/kafka/pull/15640#discussion_r1585390985


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java:
##########
@@ -273,9 +310,18 @@ void cleanup() {
             log.error("Unexpected error during shutdown.  Proceed with 
closing.", e);
         } finally {
             sendUnsentRequests(timer);
+
+            LinkedList<ApplicationEvent> allEvents = new LinkedList<>();
+            applicationEventQueue.drainTo(allEvents);
+            List<CompletableApplicationEvent<?>> completableEvents = allEvents
+                    .stream()
+                    .filter(e -> e instanceof CompletableApplicationEvent<?>)
+                    .map(e -> (CompletableApplicationEvent<?>) e)
+                    .collect(Collectors.toList());

Review Comment:
   This logic is always needed whenever we `reapIncomplete`, and is currently 
repeated when we call it from the AsyncConsumer or here, so what about we move 
it into the `reapIncomplete`, make it receive a list of all events and 
internally filter the ones that are `CompletableEvent`



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