dajac commented on code in PR #15462: URL: https://github.com/apache/kafka/pull/15462#discussion_r1514893077
########## 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: I actually considered this but eventually rejected it because those new methods could also be used with a different handling than `exceptionally`. The separation of concerns would not be too good in my opinion. I was also considering adding an helper like `mapExceptionally` to add an exception handler on a list of futures. Do you think that it could also help? -- 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