<i18n dev> RFR: 8335668: NumberFormat integer only parsing should throw exception for edge case [v2]

Justin Lu jlu at openjdk.org
Tue Jul 9 20:29:48 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.

Justin Lu has updated the pull request incrementally with one additional commit since the last revision:

  reflect review

-------------

Changes:
  - all: https://git.openjdk.org/jdk/pull/20101/files
  - new: https://git.openjdk.org/jdk/pull/20101/files/522b8381..a11d3468

Webrevs:
 - full: https://webrevs.openjdk.org/?repo=jdk&pr=20101&range=01
 - incr: https://webrevs.openjdk.org/?repo=jdk&pr=20101&range=00-01

  Stats: 4 lines in 2 files changed: 2 ins; 0 del; 2 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