Integrated: 8335668: NumberFormat integer only parsing should throw exception for edge case
Justin Lu
jlu at openjdk.org
Thu Jul 11 18:44:05 UTC 2024
On Tue, 9 Jul 2024 18:42:25 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.
This pull request has now been integrated.
Changeset: 5100303c
Author: Justin Lu <jlu at openjdk.org>
URL: https://git.openjdk.org/jdk/commit/5100303c6c5e4224d2c41f90719139bb5f4e236e
Stats: 67 lines in 3 files changed: 56 ins; 0 del; 11 mod
8335668: NumberFormat integer only parsing should throw exception for edge case
Reviewed-by: naoto
-------------
PR: https://git.openjdk.org/jdk/pull/20101
More information about the core-libs-dev
mailing list