From d6395369ea5d2293db9e9d84013435abc9588703 Mon Sep 17 00:00:00 2001 From: frankvicky Date: Tue, 7 Jan 2025 20:01:12 +0800 Subject: [PATCH] MINOR: Replace ImplicitConversions with CollectionConverters --- .../kafka/server/GroupCoordinatorBaseRequestTest.scala | 5 ++--- .../kafka/server/ShareFetchAcknowledgeRequestTest.scala | 9 ++++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/core/src/test/scala/unit/kafka/server/GroupCoordinatorBaseRequestTest.scala b/core/src/test/scala/unit/kafka/server/GroupCoordinatorBaseRequestTest.scala index 7db5258b8e4ef..916c244c2954d 100644 --- a/core/src/test/scala/unit/kafka/server/GroupCoordinatorBaseRequestTest.scala +++ b/core/src/test/scala/unit/kafka/server/GroupCoordinatorBaseRequestTest.scala @@ -36,7 +36,6 @@ import org.junit.jupiter.api.Assertions.{assertEquals, fail} import java.util.{Comparator, Properties} import java.util.stream.Collectors import scala.collection.Seq -import scala.collection.convert.ImplicitConversions.{`collection AsScalaIterable`, `map AsScala`} import scala.jdk.CollectionConverters._ import scala.reflect.ClassTag @@ -123,11 +122,11 @@ class GroupCoordinatorBaseRequestTest(cluster: ClusterInstance) { } protected def getTopicIds: Map[String, Uuid] = { - cluster.controllers().get(cluster.controllerIds().iterator().next()).controller.findAllTopicIds(ANONYMOUS_CONTEXT).get().toMap + cluster.controllers().get(cluster.controllerIds().iterator().next()).controller.findAllTopicIds(ANONYMOUS_CONTEXT).get().asScala.toMap } protected def getBrokers: Seq[KafkaBroker] = { - cluster.brokers.values().stream().collect(Collectors.toList[KafkaBroker]).toSeq + cluster.brokers.values().stream().collect(Collectors.toList[KafkaBroker]).asScala.toSeq } protected def bootstrapServers(): String = { diff --git a/core/src/test/scala/unit/kafka/server/ShareFetchAcknowledgeRequestTest.scala b/core/src/test/scala/unit/kafka/server/ShareFetchAcknowledgeRequestTest.scala index 73f9fce42e6b1..4a816d51c2dc4 100644 --- a/core/src/test/scala/unit/kafka/server/ShareFetchAcknowledgeRequestTest.scala +++ b/core/src/test/scala/unit/kafka/server/ShareFetchAcknowledgeRequestTest.scala @@ -29,7 +29,6 @@ import org.junit.jupiter.api.extension.ExtendWith import java.util import java.util.Collections -import scala.collection.convert.ImplicitConversions.`list asScalaBuffer` import scala.jdk.CollectionConverters._ @Timeout(1200) @@ -266,7 +265,7 @@ class ShareFetchAcknowledgeRequestTest(cluster: ClusterInstance) extends GroupCo val partitionsCount = shareFetchResponseData.responses().get(0).partitions().size() if (partitionsCount > 0) { assertEquals(topicId, shareFetchResponseData.responses().get(0).topicId()) - shareFetchResponseData.responses().get(0).partitions().foreach(partitionData => { + shareFetchResponseData.responses().get(0).partitions().asScala.foreach(partitionData => { if (!partitionData.acquiredRecords().isEmpty) { responses = responses :+ partitionData } @@ -2275,7 +2274,7 @@ class ShareFetchAcknowledgeRequestTest(cluster: ClusterInstance) extends GroupCo val partitionsCount = shareFetchResponseData.responses().get(0).partitions().size() if (partitionsCount > 0) { assertEquals(topicId, shareFetchResponseData.responses().get(0).topicId()) - shareFetchResponseData.responses().get(0).partitions().foreach(partitionData => { + shareFetchResponseData.responses().get(0).partitions().asScala.foreach(partitionData => { if (!partitionData.acquiredRecords().isEmpty) { responses = responses :+ partitionData } @@ -2322,7 +2321,7 @@ class ShareFetchAcknowledgeRequestTest(cluster: ClusterInstance) extends GroupCo val shareFetchResponseData = shareFetchResponse.data() assertEquals(Errors.NONE.code, shareFetchResponseData.errorCode) - shareFetchResponseData.responses().foreach(response => { + shareFetchResponseData.responses().asScala.foreach(response => { if (!response.partitions().isEmpty) { response.partitions().forEach(partitionData => partitions.add(partitionData.partitionIndex)) } @@ -2334,7 +2333,7 @@ class ShareFetchAcknowledgeRequestTest(cluster: ClusterInstance) extends GroupCo private def expectedAcquiredRecords(firstOffsets: util.List[Long], lastOffsets: util.List[Long], deliveryCounts: util.List[Int]): util.List[AcquiredRecords] = { val acquiredRecordsList: util.List[AcquiredRecords] = new util.ArrayList() - for (i <- firstOffsets.indices) { + for (i <- firstOffsets.asScala.indices) { acquiredRecordsList.add(new AcquiredRecords() .setFirstOffset(firstOffsets.get(i)) .setLastOffset(lastOffsets.get(i))