Skip to content

[ISSUE #10853] fix(store): validate HA state ordinals - #10858

Open
yuluo-yx wants to merge 2 commits into
apache:developfrom
yuluo-yx:0808-yuluo/fix-15
Open

[ISSUE #10853] fix(store): validate HA state ordinals#10858
yuluo-yx wants to merge 2 commits into
apache:developfrom
yuluo-yx:0808-yuluo/fix-15

Conversation

@yuluo-yx

@yuluo-yx yuluo-yx commented Aug 8, 2026

Copy link
Copy Markdown
Member

Which Issue(s) This PR Fixes

Brief Description

Adds bounds-checked HA state decoding. The server rejects unknown slave state ordinals and the client logs mismatched unknown master states without indexing outside the enum array. Adds boundary tests for state decoding.

How Did You Test This Change?

mise x java@temurin-17 -- mvn -Dmaven.repo.local=/private/tmp/rocketmq-m2 -pl store -am -DskipITs -Dtest=HAConnectionStateTest -Dsurefire.failIfNoSpecifiedTests=false test

The targeted tests, Checkstyle, and SpotBugs completed successfully.

@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.

Summary

The change correctly replaces unchecked HAConnectionState.values()[ordinal] lookups with a bounds-safe fromOrdinal helper, preventing ArrayIndexOutOfBoundsException on malformed HA state ordinals. However, the newly added test file contains a malformed annotation that will block compilation, so that must be fixed before merge. Additionally, the contributor CLA is unsigned, which must be resolved prior to approval.


Automated review by github-manager-bot

@codecov-commenter

codecov-commenter commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 48.44%. Comparing base (fd0c959) to head (74645a0).

Files with missing lines Patch % Lines
...mq/store/ha/autoswitch/AutoSwitchHAConnection.java 80.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop   #10858      +/-   ##
=============================================
+ Coverage      48.39%   48.44%   +0.05%     
+ Complexity     13562    13552      -10     
=============================================
  Files           1380     1380              
  Lines         101165   101171       +6     
  Branches       13127    13129       +2     
=============================================
+ Hits           48962    49017      +55     
+ Misses         46233    46148      -85     
- Partials        5970     6006      +36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@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.

Summary

The malformed test annotation from the previous review has been fixed. The fromOrdinal helper is correctly bounds-checked, server-side properly rejects unknown slave state ordinals, and client-side safely handles unknown master states via null return. Tests cover boundary cases adequately. LGTM.


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.

Auto-switch HA readers do not handle unknown state ordinals safely

3 participants