On Mon, 29 Jun 2026 16:36:00 GMT, Justin Lu <[email protected]> wrote:
>> This PR addresses an edge case where the `Locale.LanguageRange(String, >> double)` constructor accepts `Double.NaN` as a weight. A `LanguageRange` >> weight is specified by >> https://datatracker.ietf.org/doc/html/rfc2616#section-3.9 and must be >> between 0.0 and 1.0, inclusive. The existing bounds checks do not handle >> this case. This change adds an explicit `Double.isNaN(weight)` check. >> >> The issue does not affect parsed range strings in the same way, since the >> input is normalized to lower case before parsing and `"nan"` is not accepted >> by `Double.parseDouble`. However, I added a test for that case as well, >> since one did not previously exist. >> >> --------- >> - [x] I confirm that I make this contribution in accordance with the >> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai). > > Justin Lu has updated the pull request incrementally with one additional > commit since the last revision: > > Review: Add implNote to parse methods Not directly related to this PR, but since this is touching weight validation, I think it would be clearer to update the IAE message for out-of-range weights to say that the bounds are inclusive, for example: It must be between 0.0 and 1.0, inclusive. src/java.base/share/classes/java/util/Locale.java line 3344: > 3342: * string using {@link Double#parseDouble(String)}. As a > result, some > 3343: * non-RFC 2616 forms of otherwise in range values, such as one > with a leading > 3344: * sign, may be accepted. I'd spell out the accepted deviations explicitly, such as a leading sign, more than three fractional digits, and scientific notation ------------- PR Review: https://git.openjdk.org/jdk/pull/31697#pullrequestreview-4594180053 PR Review Comment: https://git.openjdk.org/jdk/pull/31697#discussion_r3493699807
