beautyarbutin opened a new pull request, #11200:
URL: https://github.com/apache/rocketmq/pull/11200

   ### Which Issue(s) This PR Fixes
   
   - Fixes #10853
   
   ### Brief Description
   
   The auto-switch HA server and client decoded peer-provided state ordinals by 
indexing `HAConnectionState.values()` directly. A malformed or newer peer could 
therefore trigger `ArrayIndexOutOfBoundsException` in either read path instead 
of failing the HA connection cleanly.
   
   This change adds a bounds-checked `HAConnectionState.fromOrdinal` decoder. 
Both readers now reject unknown state values, log the original ordinal, and 
return `false` through the existing HA read-failure path. Valid state ordinals 
retain their existing handshake and transfer behavior.
   
   This reimplements the fix from the earlier, closed PR #10858 against the 
current `develop` branch. Thanks to @yuluo-yx for the original report and patch.
   
   ### How Did You Test This Change?
   
   - Red-first regression: before the fix, an unknown slave state caused 
`ArrayIndexOutOfBoundsException` in `HAServerReader.processReadResult`.
   - `mvn -B -ntp -pl store -DskipITs 
-Dtest=HAConnectionStateTest,AutoSwitchHAStateValidationTest test`
   - Result: 3 tests passed, with no failures, errors, or skips.
   - Also included the existing `AutoSwitchHATest` in a compatibility run; it 
remains skipped by its existing test annotation.
   - Checkstyle: 0 violations.
   - SpotBugs: 0 bugs and 0 errors.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to