rreddy-22 commented on code in PR #15150:
URL: https://github.com/apache/kafka/pull/15150#discussion_r1459868777


##########
core/src/main/scala/kafka/admin/ConsumerGroupCommand.scala:
##########
@@ -187,16 +197,69 @@ object ConsumerGroupCommand extends Logging {
     }
 
     def listGroups(): Unit = {
-      if (opts.options.has(opts.stateOpt)) {
-        val stateValue = opts.options.valueOf(opts.stateOpt)
-        val states = if (stateValue == null || stateValue.isEmpty)
-          Set[ConsumerGroupState]()
-        else
-          consumerGroupStatesFromString(stateValue)
-        val listings = listConsumerGroupsWithState(states)
-        printGroupStates(listings.map(e => (e.groupId, e.state.get.toString)))
-      } else
+      val includeState = opts.options.has(opts.stateOpt)
+      val includeType = opts.options.has(opts.typeOpt)
+
+      val groupInfoMap = mutable.Map[String, (String, String)]()
+
+      if (includeType || includeState) {
+        val states = getStateValues()
+        val types = getTypeValues()
+        val listings = {
+          listConsumerGroupsWithFilters(states, types)
+        }
+
+        listings.foreach { listing =>
+          val groupId = listing.groupId
+          val groupType = 
listing.groupType().orElse(ConsumerGroupType.UNKNOWN).toString
+          val state = 
listing.state().orElse(ConsumerGroupState.UNKNOWN).toString
+          groupInfoMap.update(groupId, (state, groupType))
+        }
+
+        val groupInfoList = groupInfoMap.toList.map { case (groupId, (state, 
groupType)) => (groupId, state, groupType) }

Review Comment:
   Thanks for the suggestion, I'll change it. 



-- 
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]

Reply via email to