Skip to content

Commit dafea32

Browse files
committed
Fix KafkaAdminBadContextTests
Locally, I find the admin is sometimes created even with a bad host causing the test to fail. Also, topic creation logged an error but did not throw an exception. Fixed the test to expect one of two exceptions. (cherry picked from commit 257d9c3) Conflicts: spring-kafka/src/main/java/org/springframework/kafka/core/KafkaAdmin.java
1 parent cc50e25 commit dafea32

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

spring-kafka/src/main/java/org/springframework/kafka/core/KafkaAdmin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ private void addTopicsIfNeeded(AdminClient adminClient, Collection<NewTopic> top
223223
}
224224
catch (ExecutionException e) {
225225
logger.error("Failed to create topics", e.getCause());
226-
throw e.getCause();
226+
throw new KafkaException("Failed to create topics", e.getCause());
227227
}
228228
}
229229
}

spring-kafka/src/test/java/org/springframework/kafka/core/KafkaAdminBadContextTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void testContextNotLoaded() {
4545
fail("Expected Exception");
4646
}
4747
catch (IllegalStateException e) {
48-
assertThat(e.getMessage()).isEqualTo("Could not create admin");
48+
assertThat(e.getMessage()).isIn("Could not create admin", "Could not configure topics");
4949
}
5050
}
5151

0 commit comments

Comments
 (0)