Skip to content

MINOR: Enforce non-null groupState in GroupListing constructor - #23324

Open
regarmukesh3g wants to merge 1 commit into
apache:trunkfrom
regarmukesh3g:fix/group-listing-null-check
Open

MINOR: Enforce non-null groupState in GroupListing constructor#23324
regarmukesh3g wants to merge 1 commit into
apache:trunkfrom
regarmukesh3g:fix/group-listing-null-check

Conversation

@regarmukesh3g

@regarmukesh3g regarmukesh3g commented Sep 1, 2026

Copy link
Copy Markdown

Description

GroupListing's constructor validates the type parameter with
Objects.requireNonNull but not the sibling groupState parameter,
even though both are Optional<T> fields used identically throughout
the class (toString(), equals(), hashCode(), accessors).

The omission was introduced when groupState was added alongside the
pre-existing type field in KAFKA-17949 (#17763) — the constructor
pattern was copied but the requireNonNull wrapper on the new field
was dropped.

For comparison, the equivalent (deprecated) ConsumerGroupListing
class validates both of its analogous Optional fields (groupState
and type) consistently.

This PR adds the missing Objects.requireNonNull(groupState) check
and adds unit tests covering the null case for both parameters.

Validation

  • Compiles cleanly
  • All GroupListingTest tests pass (including the two new ones)
  • Verified all existing call sites across clients, tools, core,
    and connect/mirror modules always pass Optional.of(...) or
    Optional.empty(), never a raw null, for groupState — so this
    change introduces no behavioral regression
  • checkstyle passes

Reviewers: Maros Orsak maros.orsak159@gmail.com

The groupState parameter was not validated with Objects.requireNonNull,
unlike the sibling type parameter in the same constructor and unlike
the equivalent groupState field in ConsumerGroupListing. Add the
missing check and cover both null cases with unit tests.
@github-actions github-actions Bot added clients small Small PRs triage PRs from the community labels Sep 1, 2026

@see-quick see-quick left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, I wonder why Andrew didn't introduce it in https://github.com/apache/kafka/pull/17763/changes#diff-cc7bbaf7e3aedc6d4580c1d9ff876f24cd5897454c1072335dcb3269f5664287R49, but I assume that he overlooked it so LGTM, assuming test will pass 👍..

@github-actions github-actions Bot removed the triage PRs from the community label Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants