cmccabe commented on a change in pull request #8737: URL: https://github.com/apache/kafka/pull/8737#discussion_r432814786
########## 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: I guess personally I find it confusing since we're catching a particular type of exception specifically, but then just doing what we would have done anyway if we hadn't caught it (failing). Also the failure message "Alter topic should not throw exception" implies that it is catching all exceptions, but actually only catching some that the code could throw. So doubly confusing. ---------------------------------------------------------------- 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