artemlivshits commented on code in PR #12901: URL: https://github.com/apache/kafka/pull/12901#discussion_r1069963790
########## 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: The downside is double-lookup (one for get and another for insert). -- 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