You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kafka.apache.org by ij...@apache.org on 2022/02/02 14:04:33 UTC
[kafka] branch trunk updated: MINOR: Replace if/else with match in KafkaZkClient#getPartitionAssignmentForTopics (#11669)
This is an automated email from the ASF dual-hosted git repository.
ijuma pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push:
new c1896e0 MINOR: Replace if/else with match in KafkaZkClient#getPartitionAssignmentForTopics (#11669)
c1896e0 is described below
commit c1896e0bdcb1cf3dc221cf858aa1bb0d9f709bed
Author: Joseph (Ting-Chou) Lin <lm...@gmail.com>
AuthorDate: Wed Feb 2 22:02:57 2022 +0800
MINOR: Replace if/else with match in KafkaZkClient#getPartitionAssignmentForTopics (#11669)
Reviewers: Ismael Juma <is...@juma.me.uk>
---
core/src/main/scala/kafka/zk/KafkaZkClient.scala | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/core/src/main/scala/kafka/zk/KafkaZkClient.scala b/core/src/main/scala/kafka/zk/KafkaZkClient.scala
index 823d6e8..6c32acf 100644
--- a/core/src/main/scala/kafka/zk/KafkaZkClient.scala
+++ b/core/src/main/scala/kafka/zk/KafkaZkClient.scala
@@ -682,13 +682,12 @@ class KafkaZkClient private[zk] (zooKeeperClient: ZooKeeperClient, isSecure: Boo
val getDataResponses = retryRequestsUntilConnected(getDataRequests.toSeq)
getDataResponses.flatMap { getDataResponse =>
val topic = getDataResponse.ctx.get.asInstanceOf[String]
- if (getDataResponse.resultCode == Code.OK) {
- val partitionMap = TopicZNode.decode(topic, getDataResponse.data).assignment.map { case (k, v) => (k.partition, v) }
- Map(topic -> partitionMap)
- } else if (getDataResponse.resultCode == Code.NONODE) {
- Map.empty[String, Map[Int, ReplicaAssignment]]
- } else {
- throw getDataResponse.resultException.get
+ getDataResponse.resultCode match {
+ case Code.OK =>
+ val partitionMap = TopicZNode.decode(topic, getDataResponse.data).assignment.map { case (k, v) => (k.partition, v) }
+ Map(topic -> partitionMap)
+ case Code.NONODE => Map.empty[String, Map[Int, ReplicaAssignment]]
+ case _ => throw getDataResponse.resultException.get
}
}.toMap
}