<i18n dev> RFR: JDK-8326908: DecimalFormat::toPattern throws OutOfMemoryError when pattern is empty string [v2]

Naoto Sato naoto at openjdk.org
Tue Mar 5 21:41:00 UTC 2024


On Tue, 5 Mar 2024 21:23:48 GMT, Justin Lu <jlu at openjdk.org> wrote:

>> test/jdk/java/text/Format/DecimalFormat/ToPatternTest.java line 60:
>> 
>>> 58:         dFmt.setMinimumFractionDigits(minFrac);
>>> 59: 
>>> 60:         String[] patterns = dFmt.toPattern().split("\\.");
>> 
>> Instead of assuming/hardcoding the decimal separator, `DecimalFormatSymbols.getInstance(Locale.US).getDecimalSeparator()` may be better.
>
> Actually, since `toPattern()` is non-localized, it will always use "." as specified by DecimalFormat.
> 
> I removed the misleading comment `// Use a US dFmt, which uses '.' as the decimal separator` that indicated we needed to use a DecimalFormatSymbols where "." was the decimal separator. Can just simply use a DecimalFormat returned by the default constructor.

Oh right. Yes, so we should not use the US locale for this test.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/18094#discussion_r1513526760


More information about the i18n-dev mailing list