Skip to content

Conversation

@pgomulka
Copy link
Contributor

@pgomulka pgomulka commented Oct 7, 2020

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

  • Have you signed the contributor license agreement?
  • Have you followed the contributor guidelines?
  • If submitting code, have you built your formula locally prior to submission with gradle check?
  • If submitting code, is your pull request against master? Unless there is a good reason otherwise, we prefer pull requests against master and will backport as needed.
  • If submitting code, have you checked that your submission is for an OS and architecture that we support?
  • If you are submitting this code for a class then read our policy for that.

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
@pgomulka pgomulka added :Core/Infra/Core Core issues without another label >test-failure Triaged test failures from CI labels Oct 7, 2020
@pgomulka pgomulka self-assigned this Oct 7, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (:Core/Infra/Core)

@elasticmachine elasticmachine added the Team:Core/Infra Meta label for core/infra team label Oct 7, 2020
@pgomulka pgomulka requested a review from imotov October 7, 2020 16:20
Copy link
Member

@rjernst rjernst left a comment

Choose a reason for hiding this comment

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

LGTM

}

public static byte randomNonNegativeByte() {
byte randomByte = (byte) random().nextInt();
Copy link
Member

Choose a reason for hiding this comment

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

nit: just use randomByte()?

Copy link
Contributor

@imotov imotov left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks!

@pgomulka pgomulka merged commit 9b056e1 into elastic:master Oct 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Core Core issues without another label Team:Core/Infra Meta label for core/infra team >test-failure Triaged test failures from CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CI] XContentTypeTests.testVersionParsing fails reproducibly

4 participants