vinothchandar commented on a change in pull request #8737: URL: https://github.com/apache/kafka/pull/8737#discussion_r431978052
########## File path: core/src/main/scala/kafka/admin/TopicCommand.scala ########## @@ -247,8 +247,12 @@ object TopicCommand extends Logging { val createResult = adminClient.createTopics(Collections.singleton(newTopic)) createResult.all().get() println(s"Created topic ${topic.name}.") - } else { - throw new IllegalArgumentException(s"Topic ${topic.name} already exists") + } catch { + case e : ExecutionException => + if (e.getCause == null) + throw e + if (!e.getCause.isInstanceOf[TopicExistsException] || !topic.ifTopicDoesntExist()) Review comment: Part of the issue here is I wanted to throw e, if the cause is null.. So I needed to check for that anyway. I was debating the `||` vs `&&` there. With the `if` you mentioned, I need to return out of the method, instead of throwing.. I prefer to keep this the way it is. ---------------------------------------------------------------- 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