<i18n dev> RFR: 8319640: ClassicFormat::parseObject (from DateTimeFormatter) does not conform to the javadoc and may leak DateTimeException

Joe Wang joehw at openjdk.org
Fri Nov 10 01:22:57 UTC 2023


On Thu, 9 Nov 2023 17:44:44 GMT, Naoto Sato <naoto at openjdk.org> wrote:

> Fixing the `Format::parseObject(String, ParsePosition)` implementation in `DateTimeFormatter` class, to not throw `DateTimeException` but to return null.

test/jdk/java/time/test/java/time/format/TestDateTimeParsing.java line 260:

> 258:             .toFormatter(Locale.ROOT)
> 259:             .toFormat();
> 260:         assertEquals(f.parseObject("17-30", new ParsePosition(0)), null);

I might have missed it, but this test doesn't seem to exercise the situation where IOOBE would happen. Though the result would be the same as it catches RuntimeException always, I wonder whether an additional test case would be helpful to verify the IOOBE situation, e.g. set the position to be greater than the length.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/16586#discussion_r1388762259


More information about the i18n-dev mailing list