I have two separate test classes. Both of them when boot up individually create two beans each of instance KafkaConsumer. These tests are for event listeners which use these consumers to poll from the subscribed topic. Let's call these beans x and y. If I run these test classes individually they run as they should.
Now if I try to run these tests simultaneously. The first test passes but while shutting down the resources it says
"Destroy method 'close' on bean with name 'x' threw an exception: java.util.ConcurrentModificationException: KafkaConsumer is not safe for multi-threaded access"
"Destroy method 'close' on bean with name 'y' threw an exception: java.util.ConcurrentModificationException: KafkaConsumer is not safe for multi-threaded access"
Then the second test starts but the consumer keeps on polling without processing the event that was published to the topic it is listening to and eventually the second test times out.
I am not sure if this is the reason for the failing of subsequent test but I have only figured this to be the probable issue for the behaviour. I still get the exception if i manually try to destroy the beans adter the first test has executed.
Aucun commentaire:
Enregistrer un commentaire