cmccabe commented on a change in pull request #8737:
URL: https://github.com/apache/kafka/pull/8737#discussion_r432158637



##########
File path: core/src/main/scala/kafka/admin/TopicCommand.scala
##########
@@ -259,7 +263,8 @@ object TopicCommand extends Logging {
     override def alterTopic(opts: TopicCommandOptions): Unit = {
       val topic = new CommandTopicPartition(opts)
       val topics = getTopics(opts.topic, opts.excludeInternalTopics)
-      ensureTopicExists(topics, opts.topic)
+      ensureTopicExists(topics, opts.topic, !opts.ifExists)

Review comment:
       I don't think this is really enough to accomplish your goal here.  With 
this code, if the topic does not exist, we will get past this line but then 
fail on the next line in `describeTopics, with a 
`NoSuchTopicOrPartitionException`.
   
   I think it would be better to simply catch the 
`NoSuchTopicOrPartitionException` and handle it appropriately like we did with 
topic creation.  This also avoids the redunant calls in `ensureTopicExists`.




----------------------------------------------------------------
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


Reply via email to