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



##########
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:
       So this is an execution of `testAlterWhenTopicDoesntExistWithIfExists` 
altering a non-existing topic using `-if-exists` . As you can see, `topics` is 
empty.. The cleaner thing to do here seems to be just place any further calls 
into a `if (topics.nonEmpty) { .. }` block.. 
   
   Is your intention here, avoiding the call to `getTopics()` and 
`ensureTopicExists()`?  That was the model I was referring to above. if you 
concern is `describeTopics` failing, then it does not seem to be happening.. 
(but this code is on thin-ice, agree. if someone changes behavior of 
describeTopics, then this will break, but so will the test I added.) 
   
   
![image](https://user-images.githubusercontent.com/1179324/83203309-038e0d80-a0fe-11ea-90a7-46abed714aa2.png)
   




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