[BUG] EndTransactionProcessor NPEs when the prepared message lacks the producer group property - #11096
Open
zjncs wants to merge 1 commit into
Open
[BUG] EndTransactionProcessor NPEs when the prepared message lacks the producer group property#11096zjncs wants to merge 1 commit into
zjncs wants to merge 1 commit into
Conversation
…rocessor checkPrepareMessage dereferenced the PROPERTY_PRODUCER_GROUP value read from the prepared message without a null check, so a half message that lacks the property (written by an old client or restored from a store without it) failed the whole commit/rollback request with an NPE instead of the intended 'producer group wrong' rejection. Use Objects.equals, which treats a missing property as a mismatch. Signed-off-by: zjncs <18910855655@163.com>
RockteMQ-AI
approved these changes
Sep 9, 2026
RockteMQ-AI
left a comment
Contributor
There was a problem hiding this comment.
Summary
Replaces pgroupRead.equals(...) with Objects.equals(pgroupRead, ...) to handle the case where the prepared message lacks the PROPERTY_PRODUCER_GROUP property — prevents NPE and returns the intended error response instead. Consistent with the topic check directly above it. Regression test included.
LGTM.
Automated review by github-manager-bot
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.
Motivation
EndTransactionProcessor.checkPrepareMessagevalidates the request's producer group against the property stored on the prepared (half) message:If the half message does not carry
PROPERTY_PRODUCER_GROUP(half messages written by old clients, or stores restored without the property),pgroupReadis null and the commit/rollback request dies with:The topic check right above already tolerates a missing field defensively (
StringUtils.isNotBlank+Objects.equals), so the producer-group check is inconsistent with its own file's style.Changes
Objects.equals(pgroupRead, requestHeader.getProducerGroup()): a missing property is a mismatch and gets the intendedSYSTEM_ERROR/ "The producer group wrong" rejection instead of an NPE.Verification
New test
testProcessRequestRejectsPreparedMessageWithoutProducerGroup: commits a transaction whose prepared message has the producer-group property removed.