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



##########
File path: 
clients/src/main/java/org/apache/kafka/common/requests/MetadataRequest.java
##########
@@ -92,6 +93,13 @@ public MetadataRequest build(short version) {
             if (!data.allowAutoTopicCreation() && version < 4)
                 throw new UnsupportedVersionException("MetadataRequest 
versions older than 4 don't support the " +
                         "allowAutoTopicCreation field");
+            if (data.topics() != null) {
+                data.topics().forEach(topic -> {
+                    if (topic.name() == null || topic.topicId() != 
Uuid.ZERO_UUID)
+                        throw new UnsupportedVersionException("MetadataRequest 
version " + version  +

Review comment:
       On second though, would it be better to have a separate exception 
message for each condition?

##########
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.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("")

Review comment:
       It's odd to do this here. Seems like `getErrorResponse` should handle 
this case in general?




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