dajac commented on code in PR #13240:
URL: https://github.com/apache/kafka/pull/13240#discussion_r1121488495


##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -425,35 +425,63 @@ class KafkaApis(val requestChannel: RequestChannel,
       requestHelper.sendMaybeThrottle(request, 
offsetCommitRequest.getErrorResponse(Errors.UNSUPPORTED_VERSION.exception))
       CompletableFuture.completedFuture[Unit](())
     } else {
+      val topicNames =
+        if (offsetCommitRequest.version() >= 9)
+          metadataCache.topicIdsToNames()
+        else
+          Collections.emptyMap[Uuid, String]()
+
+      val resolvedTopics = new 
ArrayBuffer[OffsetCommitRequestData.OffsetCommitRequestTopic]()
+      offsetCommitRequest.data.topics.forEach { topic =>
+        var topicName = topic.name()
+        if (Utils.isBlank(topicName)) {
+          // Expected for requests version >= 9 which rely on topic IDs 
exclusively.
+          topicName = topicNames.get(topic.topicId())
+        }
+        if (topicName != null) {
+          topic.setName(topicName)
+          resolvedTopics += topic
+        }
+      }
+
       val authorizedTopics = authHelper.filterByAuthorized(
         request.context,
         READ,
         TOPIC,
-        offsetCommitRequest.data.topics.asScala
+        resolvedTopics
       )(_.name)
 
-      val responseBuilder = new OffsetCommitResponse.Builder()
+      val responseBuilder = 
OffsetCommitResponse.newBuilder(offsetCommitRequest.version())
       val authorizedTopicsRequest = new 
mutable.ArrayBuffer[OffsetCommitRequestData.OffsetCommitRequestTopic]()
       offsetCommitRequest.data.topics.forEach { topic =>
-        if (!authorizedTopics.contains(topic.name)) {
+        if (Utils.isBlank(topic.name)) {

Review Comment:
   I would move this up and do it in the first iteration.



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

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to