chia7712 commented on code in PR #15462: URL: https://github.com/apache/kafka/pull/15462#discussion_r1514944319
########## group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupCoordinatorService.java: ########## @@ -498,29 +497,17 @@ public CompletableFuture<ListGroupsResponseData> listGroups( ); } - final Set<TopicPartition> existingPartitionSet = runtime.partitions(); - - if (existingPartitionSet.isEmpty()) { - return CompletableFuture.completedFuture(new ListGroupsResponseData()); - } - - final List<CompletableFuture<List<ListGroupsResponseData.ListedGroup>>> futures = - new ArrayList<>(); - - for (TopicPartition tp : existingPartitionSet) { - futures.add(runtime.scheduleReadOperation( - "list-groups", - tp, - (coordinator, lastCommittedOffset) -> coordinator.listGroups(request.statesFilter(), request.typesFilter(), lastCommittedOffset) - ).exceptionally(exception -> { - exception = Errors.maybeUnwrapException(exception); - if (exception instanceof NotCoordinatorException) { - return Collections.emptyList(); - } else { - throw new CompletionException(exception); - } - })); - } + final List<CompletableFuture<List<ListGroupsResponseData.ListedGroup>>> futures = runtime.scheduleReadAllOperation( + "list-groups", + (coordinator, lastCommittedOffset) -> coordinator.listGroups(request.statesFilter(), request.typesFilter(), lastCommittedOffset) + ).stream().map(future -> future.exceptionally(exception -> { Review Comment: > adding an helper like mapExceptionally to add an exception handler on a list of futures Do you mean to enhance `FutureUtils#combineFutures` to take one more parameter? Current PR is good to me but I'd like to see more design (`mapExceptionally`) before merging :) -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org