private <T> CoordinatorResult<T, CoordinatorRecord> consumerGroupFenceMember(
        ConsumerGroup group,
        ConsumerGroupMember member,
        T response
    ) {
        if (validateOnlineDowngrade(group, member.memberId())) {
            return convertToClassicGroup(group, member.memberId(), response);
        } else {
            List<CoordinatorRecord> records = new ArrayList<>();
            removeMember(records, group.groupId(), member.memberId());

            // We update the subscription metadata without the leaving member.
            Map<String, TopicMetadata> subscriptionMetadata = group.computeSubscriptionMetadata(
                group.computeSubscribedTopicNames(member, null),
                metadataImage.topics(),
                metadataImage.cluster()
            );

            if (!subscriptionMetadata.equals(group.subscriptionMetadata())) {
                log.info("[GroupId {}] Computed new subscription metadata: {}.",
                    group.groupId(), subscriptionMetadata);
                records.add(newGroupSubscriptionMetadataRecord(group.groupId(), subscriptionMetadata));
            }

            // We bump the group epoch.
            int groupEpoch = group.groupEpoch() + 1;
            records.add(newGroupEpochRecord(group.groupId(), groupEpoch));

            cancelTimers(group.groupId(), member.memberId());

            return new CoordinatorResult<>(records, response);
        }
    }
Fences a member from a consumer group and maybe downgrade the consumer group to a classic group.

@param group     The group.
@param member    The member.
@param response  The response of the CoordinatorResult.

@return The CoordinatorResult to be applied.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java