KEMBAR78
java.lang.IllegalStateException: Only one 'RetryTopicConfigurationSupport' is allowed when Spring context is reloaded · Issue #2477 · spring-projects/spring-kafka · GitHub
Skip to content

java.lang.IllegalStateException: Only one 'RetryTopicConfigurationSupport' is allowed when Spring context is reloaded #2477

@jrenzullo

Description

@jrenzullo

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions