splett2 commented on a change in pull request #9628: URL: https://github.com/apache/kafka/pull/9628#discussion_r534494510
########## File path: core/src/main/scala/kafka/server/AdminManager.scala ########## @@ -920,32 +954,49 @@ class AdminManager(val config: KafkaConfig, !name.isDefined || !strict } - def fromProps(props: Map[String, String]): Map[String, Double] = { - props.map { case (key, value) => - val doubleValue = try value.toDouble catch { - case _: NumberFormatException => - throw new IllegalStateException(s"Unexpected client quota configuration value: $key -> $value") - } - key -> doubleValue - } - } - - (userEntries ++ clientIdEntries ++ bothEntries).map { case ((u, c), p) => + (userEntries ++ clientIdEntries ++ bothEntries).flatMap { case ((u, c), p) => val quotaProps = p.asScala.filter { case (key, _) => QuotaConfigs.isQuotaConfig(key) } if (quotaProps.nonEmpty && matches(userComponent, u) && matches(clientIdComponent, c)) Some(userClientIdToEntity(u, c) -> fromProps(quotaProps)) else None - }.flatten.toMap + }.toMap Review comment: this was just a coding style change, from calling `entries.map(...).flatten()` => `entries.flatMap` ########## File path: core/src/main/scala/kafka/server/AdminManager.scala ########## @@ -920,32 +954,49 @@ class AdminManager(val config: KafkaConfig, !name.isDefined || !strict } - def fromProps(props: Map[String, String]): Map[String, Double] = { - props.map { case (key, value) => - val doubleValue = try value.toDouble catch { - case _: NumberFormatException => - throw new IllegalStateException(s"Unexpected client quota configuration value: $key -> $value") - } - key -> doubleValue - } - } - - (userEntries ++ clientIdEntries ++ bothEntries).map { case ((u, c), p) => + (userEntries ++ clientIdEntries ++ bothEntries).flatMap { case ((u, c), p) => val quotaProps = p.asScala.filter { case (key, _) => QuotaConfigs.isQuotaConfig(key) } if (quotaProps.nonEmpty && matches(userComponent, u) && matches(clientIdComponent, c)) Some(userClientIdToEntity(u, c) -> fromProps(quotaProps)) else None - }.flatten.toMap + }.toMap Review comment: this was just a coding style change, from calling `entries.map(...).flatten()` => `entries.flatMap()` ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org