MINOR: Replace if/else with match in KafkaZkClient#getPartitionAssignmentForTopics
Reviewers: Ismael Juma
@@ -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) {
+ getDataResponse.resultCode match {
+ case 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
+ case Code.NONODE => Map.empty[String, Map[Int, ReplicaAssignment]]
+ case _ => throw getDataResponse.resultException.get
}
}.toMap
}
