Description
Sometimes, the thread will be blocked and never continue (state: waiting) after invoke KafkaConsumer.close(). Here are the related thread dump:
Thread 73 (pool-5-thread-1): State: WAITING Blocked count: 25 Waited count: 22 Waiting on org.apache.kafka.clients.consumer.internals.AbstractCoordinator$HeartbeatThread@565a2927 Stack: java.lang.Object.wait(Native Method) java.lang.Thread.join(Thread.java:1257) java.lang.Thread.join(Thread.java:1331) org.apache.kafka.clients.consumer.internals.AbstractCoordinator.closeHeartbeatThread(AbstractCoordinator.java:385) org.apache.kafka.clients.consumer.internals.AbstractCoordinator.close(AbstractCoordinator.java:1010) org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.close(ConsumerCoordinator.java:926) org.apache.kafka.clients.consumer.KafkaConsumer.close(KafkaConsumer.java:2366) org.apache.kafka.clients.consumer.KafkaConsumer.close(KafkaConsumer.java:2333) org.apache.kafka.clients.consumer.KafkaConsumer.close(KafkaConsumer.java:2283) Thread 687 (kafka-coordinator-heartbeat-thread | XXXX-st-c35): State: WAITING Blocked count: 0 Waited count: 1 Waiting on org.apache.kafka.clients.consumer.internals.ConsumerCoordinator@51f1e632 Stack: java.lang.Object.wait(Native Method) java.lang.Object.wait(Object.java:502) org.apache.kafka.clients.consumer.internals.AbstractCoordinator$HeartbeatThread.run(AbstractCoordinator.java:1360)