private void throwIfInstanceIdIsUnreleased(ConsumerGroupMember member, String groupId, String receivedMemberId, String receivedInstanceId) {
        if (member.memberEpoch() != LEAVE_GROUP_STATIC_MEMBER_EPOCH) {
            // The new member can't join.
            log.info("[GroupId {}] Static member {} with instance id {} cannot join the group because the instance id is" +
                    " is owned by member {}.", groupId, receivedMemberId, receivedInstanceId, member.memberId());
            throw Errors.UNRELEASED_INSTANCE_ID.exception("Static member " + receivedMemberId + " with instance id "
                + receivedInstanceId + " cannot join the group because the instance id is owned by " + member.memberId() + " member.");
        }
    }
Validates if the received instanceId has been released from the group

@param member                The consumer group member.
@param groupId               The consumer group id.
@param receivedMemberId      The member id received in the request.
@param receivedInstanceId    The instance id received in the request.

@throws UnreleasedInstanceIdException if the instance id received in the request is still in use by an existing static member.
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java