kirktrue commented on code in PR #19917:
URL: https://github.com/apache/kafka/pull/19917#discussion_r2136347808


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/TopicMetadataRequestManager.java:
##########
@@ -84,16 +84,21 @@ public TopicMetadataRequestManager(final LogContext 
context, final Time time, fi
     @Override
     public NetworkClientDelegate.PollResult poll(final long currentTimeMs) {
         // Prune any requests which have timed out
-        List<TopicMetadataRequestState> expiredRequests = 
inflightRequests.stream()
-                .filter(TimedRequestState::isExpired)
-                .collect(Collectors.toList());
+        List<TopicMetadataRequestState> expiredRequests = new ArrayList<>();
+
+        for (TopicMetadataRequestState requestState : inflightRequests) {
+            if (requestState.isExpired())
+                expiredRequests.add(requestState);
+        }
+
         expiredRequests.forEach(TopicMetadataRequestState::expire);

Review Comment:
   Well, I take it back. Apparently it's not an error to remove it directly 
from the collection while iterating over the collection 🤔 



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