Skip to content

Commit

Permalink
better clean-up
Browse files Browse the repository at this point in the history
Signed-off-by: see-quick <[email protected]>
  • Loading branch information
see-quick committed Jan 13, 2025
1 parent f85749c commit 2bdfec6
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,23 @@ void setUpEach() {
void cleanUp() throws InterruptedException, ExecutionException {
Collection<String> topics = adminClientFacade.listTopic();
LOGGER.info("Kafka still contains {}", topics);
adminClientFacade.deleteTopics(topics);

if (!topics.isEmpty()) {
try {
adminClientFacade.deleteTopics(topics);
} catch (ExecutionException executionException) {
if (executionException.getCause() instanceof org.apache.kafka.common.errors.UnknownTopicOrPartitionException) {
LOGGER.warn("Some topics not found (already deleted). Ignoring ...");
} else {
throw executionException;
}
}

Collection<String> remainingTopics = adminClientFacade.listTopic();
if (!remainingTopics.isEmpty()) {
LOGGER.error("Topics still present after cleanup: {}", remainingTopics);
}
}
}

protected String generateRandomConsumerGroupName() {
Expand Down

0 comments on commit 2bdfec6

Please sign in to comment.