dajac commented on a change in pull request #10371:
URL: https://github.com/apache/kafka/pull/10371#discussion_r598687996



##########
File path: core/src/main/scala/kafka/admin/ConsumerGroupCommand.scala
##########
@@ -708,30 +711,38 @@ object ConsumerGroupCommand extends Logging {
       options.timeoutMs(t)
     }
 
-    private def parseTopicPartitionsToReset(groupId: String, topicArgs: 
Seq[String]): Seq[TopicPartition] = topicArgs.flatMap {
-      case topicArg if topicArg.contains(":") =>
-        val topicPartitions = topicArg.split(":")
-        val topic = topicPartitions(0)
-        topicPartitions(1).split(",").map(partition => new 
TopicPartition(topic, partition.toInt))
-      case topic =>
+    private def parseTopicPartitionsToReset(topicArgs: Seq[String]): 
Seq[TopicPartition] = {
+      val (topicsWithPartitions, topics) = topicArgs.partition(_.contains(":"))
+      val specifiedPartitions = topicsWithPartitions.flatMap { arg =>
+        arg.split(":") match {
+          case Array(topic, partitions) =>
+            partitions.split(",").map(partition => new TopicPartition(topic, 
partition.toInt))

Review comment:
       As we are improving the error handling, `toInt` will throw a 
`NumberFormatException` if a partition is an invalid int. How about catching it 
and throwing an `IllegalArgumentException` with a meaningful error for the user?




-- 
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:
[email protected]


Reply via email to