cmccabe commented on a change in pull request #8737: URL: https://github.com/apache/kafka/pull/8737#discussion_r432162100
########## File path: core/src/test/scala/unit/kafka/admin/TopicCommandWithAdminClientTest.scala ########## @@ -223,8 +224,20 @@ class TopicCommandWithAdminClientTest extends KafkaServerTestHarness with Loggin createAndWaitTopic(createOpts) // try to re-create the topic - intercept[IllegalArgumentException] { + intercept[TopicExistsException] { + topicService.createTopic(createOpts) + } + } + + @Test + def testCreateWhenAlreadyExistsWithIfNotExists(): Unit = { + val createOpts = new TopicCommandOptions(Array("--topic", testTopicName, "--if-not-exists")) + createAndWaitTopic(createOpts) + + try { topicService.createTopic(createOpts) + } catch { Review comment: Hmm. I don't see why these catch blocks are needed. All we're doing here is just failing when we get an exception. But an exception propagating to the top level of the test function fails the test anyway. What am I missing? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org