Under some specific conditions and error occurs when the application is stopping and the KafkaProducer is still stopping
o.a.k.clients.producer.KafkaProducer : [Producer clientId=xxx] Interrupted while joining ioThread
java.lang.InterruptedException: null
at java.base/java.lang.Object.wait(Native Method)
at java.base/java.lang.Thread.join(Thread.java:1313)
at org.apache.kafka.clients.producer.KafkaProducer.close(KafkaProducer.java:1199)
at org.apache.kafka.clients.producer.KafkaProducer.close(KafkaProducer.java:1176)
at org.apache.kafka.clients.producer.KafkaProducer.close(KafkaProducer.java:1154)
at com.github.danielwegener.logback.kafka.KafkaAppender.stop(KafkaAppender.java:74)
at ch.qos.logback.core.spi.AppenderAttachableImpl.detachAndStopAllAppenders(AppenderAttachableImpl.java:107)
I can propose a fix, but I don't know which solution is the best:
Add a close timeout (using producer.close(closeTimeout) methods) to limit the time spend waiting for the producer to stop. The logback-kafka-appender library depends on kafka-clients 1.0.0 which only has a producer.close(long, TimeUnit) which is deprecated and replaced by producer.close(Duration) in recent releases.
Under some specific conditions and error occurs when the application is stopping and the KafkaProducer is still stopping
I can propose a fix, but I don't know which solution is the best:
producer.close(closeTimeout)
methods) to limit the time spend waiting for the producer to stop. The logback-kafka-appender library depends on kafka-clients 1.0.0 which only has aproducer.close(long, TimeUnit)
which is deprecated and replaced byproducer.close(Duration)
in recent releases.InterruptedException