<i18n dev> RFR: 8349883: Locale.LanguageRange.parse("-") throws ArrayIndexOutOfBoundsException

Naoto Sato naoto at openjdk.org
Wed Feb 12 21:43:16 UTC 2025


On Wed, 12 Feb 2025 19:34:19 GMT, Justin Lu <jlu at openjdk.org> wrote:

> Please review this PR which prevents a (non-specified) `AIOOBE` from leaking out of the range accepting endpoints in `Locale.LanguageRange`.
> 
> In the reported error case, the invalid range is a lone "-" which is `split` into an empty array. Checking if the range ends with "-" first, avoids indexing the empty array.

Looks good

test/jdk/java/util/Locale/IllformedRangeTest.java line 40:

> 38: import static org.junit.jupiter.api.Assertions.assertThrows;
> 39: 
> 40: public class IllformedRangeTest {

Instead of creating a new test file, you might want to add this test into `LanguageRangeTest.java`

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

PR Review: https://git.openjdk.org/jdk/pull/23596#pullrequestreview-2613272653
PR Review Comment: https://git.openjdk.org/jdk/pull/23596#discussion_r1953439911


More information about the i18n-dev mailing list