Skip to content

Fix potential negative index in load balancers#6928

Merged
mrniko merged 1 commit intoredisson:masterfrom
GaoSSR:fix-math-abs-overflow
Dec 31, 2025
Merged

Fix potential negative index in load balancers#6928
mrniko merged 1 commit intoredisson:masterfrom
GaoSSR:fix-math-abs-overflow

Conversation

@GaoSSR
Copy link
Contributor

@GaoSSR GaoSSR commented Dec 30, 2025

Math.abs(Integer.MIN_VALUE) returns negative value, which may cause ArrayIndexOutOfBoundsException.

}

int ind = Math.abs(index.incrementAndGet() % clientsCopy.size());
int ind = (index.incrementAndGet() & 0x7FFFFFFF) % clientsCopy.size();
Copy link
Member

@mrniko mrniko Dec 30, 2025

Choose a reason for hiding this comment

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

Consider using Math.floorMod instead

@GaoSSR GaoSSR force-pushed the fix-math-abs-overflow branch from dc4f3d8 to 7274cbf Compare December 31, 2025 02:39
@GaoSSR
Copy link
Contributor Author

GaoSSR commented Dec 31, 2025

Done, thanks for the suggestion!

@mrniko mrniko added this to the 4.1.1 milestone Dec 31, 2025
@mrniko mrniko added the bug label Dec 31, 2025
@GaoSSR
Copy link
Contributor Author

GaoSSR commented Dec 31, 2025

Excuse me, would it be possible to get to know you? I'm interested in contributing more to Redisson. looking forward to learning from you@mrniko

@mrniko
Copy link
Member

mrniko commented Dec 31, 2025

@GaoSSR

Sure. Which contact should I use?

@mrniko mrniko merged commit 46caa64 into redisson:master Dec 31, 2025
4 checks passed
@mrniko
Copy link
Member

mrniko commented Dec 31, 2025

Thanks for contribution

@GaoSSR
Copy link
Contributor Author

GaoSSR commented Dec 31, 2025

You can reach me via email: [email protected],I followed you on GitHub、Looking forward to contributing more to Redisson! @mrniko

@mrniko
Copy link
Member

mrniko commented Dec 31, 2025

I have sent an email

@GaoSSR
Copy link
Contributor Author

GaoSSR commented Dec 31, 2025

Email sent, thanks!

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

Labels

Development

Successfully merging this pull request may close these issues.

2 participants