Skip to content
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

AVRO-1523 [Perl] Fix valid range for int and long #2974

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

jjatria
Copy link
Contributor

@jjatria jjatria commented Jun 24, 2024

The check for valid int and long values was using the absolute value of the input, but in in two's complement arithmetic types the minimum and maximum values have different absolute values, which resulted in the minimum values for both types being rejected (because their absolute values are greater than those of the corresponding maxima).

This change fixes this and expands the binary encoder tests to check the ends of the accepted ranges.

The change in this PR is based on an original submission by John Karp submitted in 2014 to https://issues.apache.org/jira/browse/AVRO-1523.

Verifying this change

This change extended t/02_bin_encode.t to add tests for these scenarios, for values just in and just out of the accepted ranges, on both the lower and upper bounds.

Documentation

  • Does this pull request introduce a new feature? (yes / no)
  • If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)

The check for valid int and long values was using the absolute value of
the input, but in in two's complement arithmetic types the minimum and
maximum values have different absolute values, which resulted in the
minimum values for both types being rejected (because their absolute
values are greater than those of the corresponding maxima).

This change fixes this and expands the binary encoder tests to check
the ends of the accepted ranges.
@github-actions github-actions bot added the Perl label Jun 24, 2024
@martin-g martin-g merged commit 6863074 into apache:main Jun 25, 2024
6 checks passed
@jjatria jjatria deleted the avro-1523-numeric-minimum branch June 25, 2024 09:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants