kirktrue commented on code in PR #19917: URL: https://github.com/apache/kafka/pull/19917#discussion_r2136340952
########## 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: Because the `expire()` method removes itself from `inflightRequests`, won't that throw an exception because the for loop's underlying `Iterator` wasn't used to remove the entry? -- 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