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



##########
File path: 
core/src/test/scala/unit/kafka/server/epoch/util/ReplicaFetcherMockBlockingSend.scala
##########
@@ -78,7 +80,19 @@ class ReplicaFetcherMockBlockingSend(offsets: 
java.util.Map[TopicPartition, Epoc
         callback.foreach(_.apply())
         epochFetchCount += 1
         lastUsedOffsetForLeaderEpochVersion = 
requestBuilder.latestAllowedVersion()
-        new OffsetsForLeaderEpochResponse(currentOffsets)
+
+        val data = new OffsetForLeaderEpochResponseData()
+        currentOffsets.forEach((tp, offsetForLeaderPartition) => {
+          var topic = data.topics.find(tp.topic)
+          if (topic == null) {
+            topic = new OffsetForLeaderTopicResult()
+              .setTopic(tp.topic)
+            data.topics.add(topic)
+          }
+          
topic.partitions.add(offsetForLeaderPartition.setPartition(tp.partition))

Review comment:
       oh, it is just personal taste. the code 
```topic.partitions.add(offsetForLeaderPartition.setPartition(tp.partition))``` 
adds inner mutable object (```offsetForLeaderPartition```) to returned 
response. I prefer to add a copy of ```offsetForLeaderPartition```.




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