You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/05/19 16:22:12 UTC

[GitHub] [kafka] jolshan commented on a change in pull request #10584: KAFKA-12701: NPE in MetadataRequest when using topic IDs

jolshan commented on a change in pull request #10584:
URL: https://github.com/apache/kafka/pull/10584#discussion_r635398390



##########
File path: core/src/main/scala/kafka/server/KafkaApis.scala
##########
@@ -1142,6 +1142,19 @@ class KafkaApis(val requestChannel: RequestChannel,
     val metadataRequest = request.body[MetadataRequest]
     val requestVersion = request.header.apiVersion
 
+    // Topic IDs are not supported for versions 10 and 11. Topic names can not be null in these versions.
+    if (metadataRequest.version() >= 10 && !metadataRequest.isAllTopics) {
+      metadataRequest.data().topics().forEach{ topic =>
+        // If null, set to the empty string, since the response does not allow null.
+        if (topic.name() == null) {
+          topic.setName("")
+          throw new InvalidRequestException(s"Topic name can not be null for version ${metadataRequest.version()}")
+        } else if (topic.topicId() != Uuid.ZERO_UUID) {
+          throw new InvalidRequestException(s"Topic IDs are not supported in requests for version ${metadataRequest.version()}")
+        }
+      }
+    }

Review comment:
       We can do some there. But would we still need this since the protocol also allows for nulls/topic Ids?




-- 
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:
users@infra.apache.org