Repository navigation
Conversation
Byte, Short, Integer and Long number fields silently narrowed any cell value with intValue()/shortValue()/byteValue()/longValue(), so an out-of-range cell like 13800138000 read back as 13800138000 mod 2^32 with no error. This affected number cells and, through NumberUtils.parse*, string cells alike. Narrow through a new NumberUtils#narrowInRange that truncates toward zero (preserving the previous fractional behavior) and then checks the range with BigDecimal#compareTo, throwing ArithmeticException on overflow. Closes apache#1100
Contributor
|
Hi @BigDataDZ, Thank you for your interest. There is already a corresponding fix PR (#1101) for this issue. If you'd like, you're also welcome to review it or add further comments to the discussion there. Therefore, this PR may be closed |
Author
3 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
NumberUtils#narrowInRange(BigDecimal, long, long): truncates toward zero (preserving the previous fractional behavior) and then range-checks the truncated value withBigDecimal#compareTo, throwingArithmeticExceptionon overflow.ByteNumberConverter,ShortNumberConverter,IntegerNumberConverterandLongNumberConverternarrow through it instead of callingbyteValue()/shortValue()/intValue()/longValue()directly.NumberUtils#parseByte/#parseShort/#parseInteger/#parseLong(the string-cell path) apply the same range check, on both the plain and the DecimalFormat-backed branches.Why
An out-of-range cell silently wrapped instead of failing:
No exception was raised, so corrupted reads went unnoticed. Fractional values keep truncating as before (
123.9still reads as123); only values whose truncated integer part falls outside the target range now throw.Fixes #1100
How tested
NumberUtilsTestcases: parse* rejects out-of-range strings, accepts boundary values, and keeps truncating fractions.fesod-sheetsuite (938 tests) passes locally on Temurin 25;spotless:checkclean.