<i18n dev> RFR: 8335668: NumberFormat integer only parsing should throw exception for edge case [v2]
Naoto Sato
naoto at openjdk.org
Wed Jul 10 20:07:47 UTC 2024
On Tue, 9 Jul 2024 20:29:48 GMT, Justin Lu <jlu at openjdk.org> wrote:
>> 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.
>
> Justin Lu has updated the pull request incrementally with one additional commit since the last revision:
>
> reflect review
Marked as reviewed by naoto (Reviewer).
-------------
PR Review: https://git.openjdk.org/jdk/pull/20101#pullrequestreview-2169730057
More information about the i18n-dev
mailing list