dajac commented on a change in pull request #11971: URL: https://github.com/apache/kafka/pull/11971#discussion_r839215873
########## File path: clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java ########## @@ -3723,27 +3723,34 @@ private Integer nodeFor(ConfigResource resource) { List<MemberIdentity> membersToRemove = new ArrayList<>(); for (final MemberDescription member : members) { + MemberIdentity memberIdentity = new MemberIdentity() + .setReason(reason); + if (member.groupInstanceId().isPresent()) { - membersToRemove.add(new MemberIdentity().setGroupInstanceId(member.groupInstanceId().get())); + memberIdentity.setGroupInstanceId(member.groupInstanceId().get()); } else { - membersToRemove.add(new MemberIdentity().setMemberId(member.consumerId())); + memberIdentity.setMemberId(member.consumerId()); } + + membersToRemove.add(memberIdentity); } return membersToRemove; } @Override public RemoveMembersFromConsumerGroupResult removeMembersFromConsumerGroup(String groupId, RemoveMembersFromConsumerGroupOptions options) { + String reason = options.reason() == null || options.reason().isEmpty() ? + DEFAULT_LEAVE_GROUP_REASON : options.reason(); + List<MemberIdentity> members; if (options.removeAll()) { - members = getMembersFromGroup(groupId); + members = getMembersFromGroup(groupId, reason); } else { - members = options.members().stream().map(MemberToRemove::toMemberIdentity).collect(Collectors.toList()); + members = options.members().stream() + .map(m -> m.toMemberIdentity().setReason(reason)) + .collect(Collectors.toList()); Review comment: This is a small refactoring of the code that we did in KIP-800. It basically set the reason when the member identity is created instead of re-iterating over the members afterwards. I think that it is a bit clearer this way. I guess that we could have done like this in the original implementation but I did not think about it last time. -- 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