mirror of
https://github.com/apache/rocketmq.git
synced 2026-08-29 04:13:00 +08:00
0e4ccf1b66
DefaultElectPolicy sorted broker candidates by subtracting maxOffset values and casting the long delta to int. Large offset gaps can overflow the comparator result and rank a lower-offset broker first. This replaces subtraction with safe comparator helpers and adds a focused overflow regression test. Constraint: Preserve existing election order: higher epoch, higher maxOffset, lower electionPriority Rejected: Keep subtraction comparator | unsafe for long offset deltas greater than Integer.MAX_VALUE Confidence: high Scope-risk: narrow Tested: mvn -q -pl controller -DskipTests=false -Dtest=DefaultElectPolicyTest -Djacoco.skip=true test Tested: mvn -q -pl controller -DskipTests compile -Dspotbugs.skip=true -Dcheckstyle.skip=true Tested: mvn -q -DskipTests compile -Dspotbugs.skip=true -Dcheckstyle.skip=true Not-tested: Full controller suite on local JDK due existing JaCoCo/Hessian module-access failures Related: #10578