Description
An error is occasionally thrown when closing the AsyncKafkaConsumer:
[ERROR] 2024-06-20 17:13:54,121 [consumer_background_thread] org.apache.kafka.clients.consumer.internals.ConsumerNetworkThread lambda$configureThread$0 - Uncaught exception in thread 'consumer_background_thread': java.lang.IllegalStateException: Unknown telemetry state: TERMINATED at org.apache.kafka.common.telemetry.internals.ClientTelemetryReporter$DefaultClientTelemetrySender.timeToNextUpdate(ClientTelemetryReporter.java:363) at org.apache.kafka.clients.NetworkClient$TelemetrySender.maybeUpdate(NetworkClient.java:1392) at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:668) at org.apache.kafka.clients.consumer.internals.NetworkClientDelegate.poll(NetworkClientDelegate.java:143) at org.apache.kafka.clients.consumer.internals.ConsumerNetworkThread.sendUnsentRequests(ConsumerNetworkThread.java:299) at org.apache.kafka.clients.consumer.internals.ConsumerNetworkThread.cleanup(ConsumerNetworkThread.java:318) at org.apache.kafka.clients.consumer.internals.ConsumerNetworkThread.run(ConsumerNetworkThread.java:105)
The issue appears to be that the TERMINATED state is not expected in the switch statement inside timeToNextUpdate().
As an aside, the error message might make more sense to be written as "Unexpected telemetry state" instead of "Unknown telemetry state" since TERMINATED is a known state, but heretofore unexpected.