<i18n dev> RFR: JDK-8326908: DecimalFormat::toPattern throws OutOfMemoryError when pattern is empty string
Guoxiong Li
gli at openjdk.org
Tue Mar 5 11:56:45 UTC 2024
On Tue, 5 Mar 2024 00:15:10 GMT, Justin Lu <jlu at openjdk.org> wrote:
> For clarification, this is entirely a bug with DecimalFormat, not StringBuilder. An empty String pattern DecimalFormat sets the maximum fraction digits to Integer.MAX_VALUE. When toPattern() is invoked, the local StringBuilder will append until an OOME is thrown by the StringBuilder as there is not enough memory, when internally, the buffer is doubled for a value too large. But such an OOME would occur for any large enough value, so the issue lies with DecimalFormat.
Got it. Thanks for your explanation.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/18094#issuecomment-1978591032
More information about the i18n-dev
mailing list