Repository: apache/kafka
File: group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java (Java)

Code before:
    }

    /**
     * Gets or creates a streams group without updating the groups map.
     * The group will be materialized during the replay.
     *
     * If there is an empty classic consumer group of the same name, it will be deleted and a new streams
     * group.
     *
     * @param groupId           The group ID.
     * @param records           The record list to which the group tombstones are written
     *                          if the group is empty and is a classic group.
     *
     * @return A StreamsGroup.
     *
     * Package private for testing.
     */
    StreamsGroup getOrCreateStreamsGroup(
        String groupId,
        List<CoordinatorRecord> records
    ) {
        Group group = groups.get(groupId);

        if (group == null) {
            return new StreamsGroup(logContext, snapshotRegistry, groupId, metrics);
        } else if (maybeDeleteEmptyClassicGroup(group, records)) {
            log.info("[GroupId {}] Converted the empty classic group to a streams group.", groupId);
            return new StreamsGroup(logContext, snapshotRegistry, groupId, metrics);
        } else {
            return castToStreamsGroup(group);
        }
    }

    /**
     * Gets a streams group without updating the groups map. If the group does not exist,
     * a GroupIdNotFoundException is thrown.
     *
     * @param groupId           The group ID.
     *
     * @return A StreamsGroup.
     * @throws GroupIdNotFoundException if the group does not exist or is not a streams group.
     *
     * Package private for testing.
     */
    StreamsGroup getStreamsGroupOrThrow(
        String groupId
    ) throws GroupIdNotFoundException {
        Group group = groups.get(groupId);

        if (group == null) {
            throw new GroupIdNotFoundException(String.format("Streams group %s not found.", groupId));

Review comment (suggestion):
The method `maybeDeleteEmptyClassicGroup` is called but this method is not defined in the diff. This will cause a compilation error unless the method exists elsewhere in the codebase.

Code after:
    }

    /**
     * Gets or creates a streams group without updating the groups map.
     * The group will be materialized during the replay.
     *
     * If there is an empty classic consumer group of the same name, it will be deleted and a new streams
     * group will be created.
     *
     * @param groupId           The group ID.
     * @param records           The record list to which the group tombstones are written
     *                          if the group is empty and is a classic group.
     *
     * @return A StreamsGroup.
     *
     * Package private for testing.
     */
    StreamsGroup getOrCreateStreamsGroup(
        String groupId,
        List<CoordinatorRecord> records
    ) {
        Group group = groups.get(groupId);

        if (group == null) {
            return new StreamsGroup(logContext, snapshotRegistry, groupId, metrics);
        } else if (maybeDeleteEmptyClassicGroup(group, records)) {
            log.info("[GroupId {}] Converted the empty classic group to a streams group.", groupId);
            return new StreamsGroup(logContext, snapshotRegistry, groupId, metrics);
        } else {
            return castToStreamsGroup(group);
        }
    }

    /**
     * Gets a streams group without updating the groups map. If the group does not exist,
     * a GroupIdNotFoundException is thrown.
     *
     * @param groupId           The group ID.
     *
     * @return A StreamsGroup.
     * @throws GroupIdNotFoundException if the group does not exist or is not a streams group.
     *
     * Package private for testing.
     */
    StreamsGroup getStreamsGroupOrThrow(
        String groupId
    ) throws GroupIdNotFoundException {
        Group group = groups.get(groupId);

        if (group == null) {
            throw new GroupIdNotFoundException(String.format("Streams group %s not found.", groupId));