Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8342582

user.region for formatting number no longer works for 21.0.5

XMLWordPrintable

    • b22
    • generic
    • generic
    • Verified

        ADDITIONAL SYSTEM INFORMATION :
        Generic, at least Windows and macOS

        A DESCRIPTION OF THE PROBLEM :
        21.0.5 changed the locale fallback mechanism to no longer respect user.region in https://github.com/corretto/corretto-21/commit/a3cd6d6b916f7d8c03cd4b59324a6da11df467eb. The change should have only affected that properties can't be changed at runtime, but it breaks the existing user.region fallback logic.

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Running with -Duser.region=DE makes this test pass on 21.0.4, but fail on 21.0.5:

        Depending on your setup, you can run with -Duser.region=US and use "." as a separator in the test instead.

        EXPECTED VERSUS ACTUAL BEHAVIOR :
        EXPECTED -
        0,50000
        ACTUAL -
        0.50000

        ---------- BEGIN SOURCE ----------
        import static org.assertj.core.api.Assertions.*;
        import org.junit.jupiter.api.Test;

        class LocaleTest {

           @Test
           void test() {
              assertThat(String.format("%.5f", 0.5f)).isEqualTo("0,50000");
           }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Adding -Duser.country.format=DE fixes this issue, but not sure whether other properties need to be set.

        FREQUENCY : always


              naoto Naoto Sato
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

                Created:
                Updated:
                Resolved: