m1a2st commented on code in PR #17440: URL: https://github.com/apache/kafka/pull/17440#discussion_r1858598236
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java: ########## @@ -153,7 +154,16 @@ void runOnce() { .map(rm -> rm.maximumTimeToWait(currentTimeMs)) .reduce(Long.MAX_VALUE, Math::min); - reapExpiredApplicationEvents(currentTimeMs); + List<CompletableEvent<?>> completableEvents = reapExpiredApplicationEvents(currentTimeMs); + + // If there is a metadata error, complete the completable events which are not passed by error event with the metadata error + if (networkClientDelegate.metadataError().isPresent()) { + Throwable metadataError = networkClientDelegate.metadataError().get(); + completableEvents.stream() + .filter(event -> !(event instanceof CompletableApplicationEvent && ((CompletableApplicationEvent<?>) event).isPassedByErrorEvent())) + .forEach(event -> event.future().completeExceptionally(metadataError)); + networkClientDelegate.clearMetadataError(); Review Comment: I don't think it's necessary to execute `maybeFailOnMetadataError` before `applicationEventProcessor.process(event)`. Because, under normal situation, metadata errors only occur during the processing of events. Therefore, checking for metadata errors before processing is unnecessary. WDYT? -- 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