<i18n dev> RFR: 8335668: NumberFormat integer only parsing should throw exception for edge case
Justin Lu
jlu at openjdk.org
Tue Jul 9 18:49:44 UTC 2024
Please review this PR which corrects a case in NumberFormat integer only parsing.
[JDK-8333755](https://bugs.openjdk.org/browse/JDK-8333755) fixed integer only parsing when the value has a suffix, although it caused incorrect behavior for the following case: when the parsed string does not contain an integer portion, and the format has integer only parsing, parsing should fail, instead of 0 being returned. For example,
var fmt = NumberFormat.getIntegerInstance();
fmt.parse(".5", new ParsePosition(0)); // should return null, not 0
The changes to the _badParseStrings_ data provider in _StrictParseTest.java_ are needed since those cases _should_ fail in different indexes depending on if integer parsing is enabled. Thus, they were updated to ensure they fail for both integer and non-integer parsing with the same errorIndex.
In the fix itself, I also updated the initial value of `intIndex` to -1 from 0, to provide better clarity.
-------------
Commit messages:
- clean up + add more general test cases
- init
Changes: https://git.openjdk.org/jdk/pull/20101/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=20101&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8335668
Stats: 65 lines in 3 files changed: 54 ins; 0 del; 11 mod
Patch: https://git.openjdk.org/jdk/pull/20101.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/20101/head:pull/20101
PR: https://git.openjdk.org/jdk/pull/20101
More information about the i18n-dev
mailing list