-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix XContentTypeTests where version was a negative byte #63382
Conversation
a random byte could be -128 and when used with Math.abs it would result in an int 128. That in turn when casting back to byte would overflow and result in -128 again. Fixed with a randomNonNegativeByte method closes elastic#63342
Pinging @elastic/es-core-infra (:Core/Infra/Core) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -607,6 +607,11 @@ public static byte randomByte() { | |||
return (byte) random().nextInt(); | |||
} | |||
|
|||
public static byte randomNonNegativeByte() { | |||
byte randomByte = (byte) random().nextInt(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: just use randomByte()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
a random byte could be -128 and when used with Math.abs it would result
in an int 128. That in turn when casting back to byte would overflow and
result in -128 again.
Fixed with a randomNonNegativeByte method
closes #63342
gradle check
?