kirktrue commented on code in PR #19569: URL: https://github.com/apache/kafka/pull/19569#discussion_r2086890019
########## clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java: ########## @@ -339,11 +339,20 @@ void cleanup() { log.trace("Closing the consumer network thread"); Timer timer = time.timer(closeTimeout); try { - runAtClose(requestManagers.entries(), networkClientDelegate, time.milliseconds()); + // If an error was thrown from initializeResources(), it's possible that the list of request managers + // is null, so check before using. If the request manager list is null, there wasn't any real work + // performed, so not being able to close the request managers isn't so bad. + if (requestManagers != null) + runAtClose(requestManagers.entries(), networkClientDelegate, time.milliseconds()); Review Comment: Done. Iād convinced myself that because the `RequestManagers` instance is initialized _after_ the `NetworkClientDelegate` instance in `initializeResources()` that it wasn't strictly necessary. But it's cleaner and more defensive this way š -- 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