Details
Description
KafkaConsumer does not support multi-threaded usage and any access by a thread that does not have the lock will cause ConcurrentModificationException to be thrown.
For some users leveraging frameworks on top of Kafka that abstract the actual KafkaConsumer class/calls, it can be hard to identify user and/or framework bugs when this exception is thrown.
It would be incredibly helpful to log both the thread name and the thread ID of the thread that has acquired the lock, and the current thread that is attempting to obtain the lock in the exception message.
KafkaConsumer currently only tracks the id of the thread that has acquired the lock. Additionally, we should also keep track of the thread name.
An example of the exception message: "KafkaConsumer is not safe for multi-threaded access: acquiredThreadName=acquiredThread, acquiredThreadId=1, currentThreadName=rejectedThread, currentThreadId=2"