chia7712 commented on a change in pull request #9401:
URL: https://github.com/apache/kafka/pull/9401#discussion_r519251328



##########
File path: core/src/main/scala/kafka/server/KafkaApis.scala
##########
@@ -517,19 +517,23 @@ class KafkaApis(val requestChannel: RequestChannel,
       }
       // Note that authorization to a transactionalId implies ProducerId 
authorization
 
-    } else if (produceRequest.hasIdempotentRecords && 
!authorize(request.context, IDEMPOTENT_WRITE, CLUSTER, CLUSTER_NAME)) {
+    } else if (RequestUtils.hasIdempotentRecords(produceRequest) && 
!authorize(request.context, IDEMPOTENT_WRITE, CLUSTER, CLUSTER_NAME)) {
       sendErrorResponseMaybeThrottle(request, 
Errors.CLUSTER_AUTHORIZATION_FAILED.exception)
       return
     }
 
-    val produceRecords = produceRequest.partitionRecordsOrFail.asScala
     val unauthorizedTopicResponses = mutable.Map[TopicPartition, 
PartitionResponse]()
     val nonExistingTopicResponses = mutable.Map[TopicPartition, 
PartitionResponse]()
     val invalidRequestResponses = mutable.Map[TopicPartition, 
PartitionResponse]()
     val authorizedRequestInfo = mutable.Map[TopicPartition, MemoryRecords]()
-    val authorizedTopics = filterByAuthorized(request.context, WRITE, TOPIC, 
produceRecords)(_._1.topic)
-
-    for ((topicPartition, memoryRecords) <- produceRecords) {
+    val authorizedTopics = filterByAuthorized(request.context, WRITE, TOPIC, 
produceRequest.dataOrException().topicData().asScala)(_.topic())
+
+    produceRequest.dataOrException().topicData().forEach(topic => 
topic.data().forEach { partition =>
+      val topicPartition = new TopicPartition(topic.topic(), 
partition.partition())
+      // This caller assumes the type is MemoryRecords and that is true on 
current serialization
+      // We cast the type to avoid causing big change to code base.
+      // TODO: maybe we need to refactor code to avoid this casting

Review comment:
       https://issues.apache.org/jira/browse/KAFKA-10698




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