smjn commented on code in PR #17660:
URL: https://github.com/apache/kafka/pull/17660#discussion_r1828269993
##########
core/src/main/scala/kafka/server/KafkaApis.scala:
##########
@@ -1653,8 +1660,7 @@ class KafkaApis(val requestChannel: RequestChannel,
(txnCoordinator.partitionFor(key), TRANSACTION_STATE_TOPIC_NAME)
case CoordinatorType.SHARE =>
- // None check already done above
- (shareCoordinator.get.partitionFor(key),
SHARE_GROUP_STATE_TOPIC_NAME)
+ (shareCoordinator.foreach(coordinator =>
coordinator.partitionFor(SharePartitionKey.getInstance(key))),
SHARE_GROUP_STATE_TOPIC_NAME)
Review Comment:
This is the idiomatic way to handle Optionals in scala
https://www.scala-lang.org/api/2.12.7/scala/Option.html
https://stackoverflow.com/questions/6819373/why-is-foreach-better-than-get-for-scala-options
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]