jolshan commented on code in PR #12901:
URL: https://github.com/apache/kafka/pull/12901#discussion_r1068469845


##########
core/src/main/scala/kafka/coordinator/group/GroupCoordinatorAdapter.scala:
##########
@@ -397,19 +389,24 @@ class GroupCoordinatorAdapter(
     request: TxnOffsetCommitRequestData,
     bufferSupplier: BufferSupplier
   ): CompletableFuture[TxnOffsetCommitResponseData] = {
+    val currentTimeMs = time.milliseconds
     val future = new CompletableFuture[TxnOffsetCommitResponseData]()
 
     def callback(results: Map[TopicPartition, Errors]): Unit = {
       val response = new TxnOffsetCommitResponseData()
-      val byTopics = new util.HashMap[String, 
TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic]()
+      val byTopics = new mutable.HashMap[String, 
TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic]()
 
       results.forKeyValue { (tp, error) =>
-        var topic = byTopics.get(tp.topic)
-        if (topic == null) {
-          topic = new 
TxnOffsetCommitResponseData.TxnOffsetCommitResponseTopic().setName(tp.topic)
-          byTopics.put(tp.topic, topic)
-          response.topics.add(topic)
+        val topic = byTopics.get(tp.topic) match {

Review Comment:
   This seems like it could use the getOrElseUpdate method, but I'm not sure if 
we typically have side effects like adding to the response. Not a huge deal 
either way.



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