MINOR: Resolve hidden NPE in RequestQuotaTest#21587
Merged
AndrewJSchofield merged 1 commit intoapache:trunkfrom Feb 26, 2026
Merged
MINOR: Resolve hidden NPE in RequestQuotaTest#21587AndrewJSchofield merged 1 commit intoapache:trunkfrom
AndrewJSchofield merged 1 commit intoapache:trunkfrom
Conversation
apoorvmittal10
approved these changes
Feb 26, 2026
Contributor
apoorvmittal10
left a comment
There was a problem hiding this comment.
LGTM!
Maybe we want to consider to change the ShareAcknowledge RPC json to have groupId as non-nullable in subsequent PR.
chia7712
reviewed
Feb 26, 2026
|
|
||
| val groupId = shareFetchRequest.data.groupId | ||
|
|
||
| if (groupId == null) { |
Member
There was a problem hiding this comment.
This is interesting. I assumed the null check would be handled by the RPC layer, but it isn't. @AndrewJSchofield could you share some context on this?
Member
Author
There was a problem hiding this comment.
The NPE occurs in the authorizer. As mentioned, doesn't happen with a real client because group.id must be set in the consumer application config.
Member
There was a problem hiding this comment.
@AndrewJSchofield thanks for response
Maybe we want to consider to change the ShareAcknowledge RPC json to have groupId as non-nullable in subsequent PR.
+1
chia7712
approved these changes
Feb 26, 2026
Shekharrajak
pushed a commit
to Shekharrajak/kafka
that referenced
this pull request
Mar 31, 2026
`RequestQuotaTest` was silently experiencing NPE when testing `SHARE_ACKNOWLEDGE`. This is because the default for the group ID in this request is null, even though this is never actually used in practice by a real client. The construction of `ShareAcknowledgeRequestData` in this test did not initialize a specific value for group ID, and this means it was left as null. The result was an NPE handling the request in the broker, which was not the intended action of the test. The PR explicitly handles null for group ID and member ID in `SHARE_FETCH` and `SHARE_ACKNOWLEDGE` requests so that we are not relying on the overall exception handling for this situation. In practice, this would not be necessary for a real client, but the defensive code makes sense for this test (or a poorly written client). It also initialises the request in the test case with a non-null group ID and member ID for `SHARE_ACKNOWLEDGE` which aligns with what already exists for `SHARE_FETCH`. Reviewers: Apoorv Mittal <apoorvmittal10@gmail.com>, Chia-Ping Tsai <chia7712@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RequestQuotaTestwas silently experiencing NPE when testingSHARE_ACKNOWLEDGE. This is because the default for the group ID inthis request is null, even though this is never actually used in
practice by a real client. The construction of
ShareAcknowledgeRequestDatain this test did not initialize a specificvalue for group ID, and this means it was left as null. The result was
an NPE handling the request in the broker, which was not the intended
action of the test.
The PR explicitly handles null for group ID and member ID in
SHARE_FETCHandSHARE_ACKNOWLEDGErequests so that we are notrelying on the overall exception handling for this situation. In
practice, this would not be necessary for a real client, but the
defensive code makes sense for this test (or a poorly written client).
It also initialises the request in the test case with a non-null group
ID and member ID for
SHARE_ACKNOWLEDGEwhich aligns with what alreadyexists for
SHARE_FETCH.Reviewers: Apoorv Mittal apoorvmittal10@gmail.com, Chia-Ping Tsai
chia7712@gmail.com