abbccdda commented on a change in pull request #9579:
URL: https://github.com/apache/kafka/pull/9579#discussion_r570480399



##########
File path: core/src/main/scala/kafka/server/KafkaApis.scala
##########
@@ -1234,19 +1171,28 @@ class KafkaApis(val requestChannel: RequestChannel,
     // In versions 5 and below, we returned LEADER_NOT_AVAILABLE if a matching 
listener was not found on the leader.
     // From version 6 onwards, we return LISTENER_NOT_FOUND to enable 
diagnosis of configuration errors.
     val errorUnavailableListeners = requestVersion >= 6
-    val topicMetadata =
+    val (topicMetadata, nonExistTopicMetadata) =
       if (authorizedTopics.isEmpty)
-        Seq.empty[MetadataResponseTopic]
-      else {
-        getTopicMetadata(
-          metadataRequest.allowAutoTopicCreation,
-          metadataRequest.isAllTopics,
-          authorizedTopics,
-          request.context.listenerName,
-          errorUnavailableEndpoints,
-          errorUnavailableListeners
-        )
+        (Seq.empty[MetadataResponseTopic], Seq.empty[MetadataResponseTopic])
+      else
+        getTopicMetadata(metadataRequest.isAllTopics, authorizedTopics,
+          request.context.listenerName, errorUnavailableEndpoints, 
errorUnavailableListeners)
+
+    nonExistTopicMetadata.foreach(metadata =>
+      try {
+        // Validate topic name and propagate error if failed
+        Topic.validate(metadata.name())

Review comment:
       Actually after looking into the zk admin manager logic, I don't think 
it's necessary to do the topic validation here.




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