Skip to content

fix(remoting): include brokerId in SubscriptionGroupConfig.equals - #11136

Open
zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/subscription-group-config-equals-broker-id
Open

zjncs wants to merge 1 commit into
apache:developfrom
zjncs:fix/subscription-group-config-equals-broker-id

Conversation

@zjncs

@zjncs zjncs commented Sep 11, 2026

Copy link
Copy Markdown

Motivation

brokerId participates in SubscriptionGroupConfig.hashCode but was missing from equals, so two configs for the same group that differ only in brokerId compared equal while hashing differently — breaking the Object contract for any HashSet/HashMap keyed on SubscriptionGroupConfig (lookups miss, set dedup misbehaves).

Modifications

Append brokerId to equals to match hashCode.

Verification

Fail-before (new test, run against the unpatched code):

Tests run: 1, Failures: 1, Errors: 0 -- SubscriptionGroupConfigTest#testBrokerIdParticipatesInEqualsAndHashCode
java.lang.AssertionError: Values should be different. Actual: SubscriptionGroupConfig{groupName=groupA, ..., brokerId=1, ...}

Pass-after:

Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 -- SubscriptionGroupConfigTest

brokerId participates in hashCode but was missing from equals, so two
configs for the same group that differ only in brokerId compared equal
with different hash codes, breaking the Object contract for any
HashSet/HashMap keyed on SubscriptionGroupConfig. Append brokerId to
equals to match hashCode.
Copilot AI lite review requested due to automatic review settings September 11, 2026 07:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@RockteMQ-AI RockteMQ-AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Correct fix for the equals/hashCode contract violation. The test clearly demonstrates the bug (fail-before) and the fix (pass-after).


Automated review by github-manager-bot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants