In what version(s) of Spring for Apache Kafka are you seeing this issue?
Since 2.9
Describe the bug
RetryTopicConfigurationSupport has a static variable to keep track of whether or not the class has been instantiated more than once. This breaks unit tests whenever the Spring context is refreshed.
public RetryTopicConfigurationSupport() {
Assert.state(ONLY_ONE_ALLOWED.getAndSet(false), "Only one 'RetryTopicConfigurationSupport' is allowed");
}
To Reproduce
Setup a Kafka listener with a retry topic configuration. Then create a unit test where the Spring context is refreshed. I forced it by using the DirtiesContext annotation, but this can occur anytime the context is reloaded.
Expected behavior
You should be able to reset the Spring context without any unexpected side effects.
Sample
https://github.com/jrenzullo/spring-kafka-test-bug