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

PropertiesStoreTest and StoreReproducibilityTest jtreg failures due to en_CA locale

    XMLWordPrintable

Details

    • b12
    • generic
    • generic
    • Verified

    Description

      Both PropertiesStoreTest and StoreReproducibilityTest jtreg tests fail when run on a system whose default locale is en_CA (likely anything other than US)

      Issue:

      The Properties class serializes via the store method and adds a Date comment using Date.toString(), this results in a date looking like: Wed Feb 16 09:27:53 PST 2022

      The tests in question use DateTimeFormatter.ofPattern(pattern).parse(text) to read and verify the comment

      where the pattern is: "EEE MMM dd HH:mm:ss zzz uuuu"

      This will parse successfully on US systems, however DateTimeFormatter uses the default locale which for en_CA expects the strings for EEE and MMM to end in a period/full-stop e.g.

      Wed. Feb. 16 09:27:53 PST 2022

      Root cause:

      Date.toString() always outputs in "US" styled format (it doesn't use any localization)

      DateFormatter.ofPattern(pattern).parse(text) defaults to the current locale

      Solution:

      Change the tests to use US locale: DateTimeFormatter.ofPattern(pattern, Locale.US).parse(text)

      Recommendations:

      Add a further test to check for regressions in either of Date or DateTimeFormatter by testing:

      DateTimeFormatter.ofPattern("EEE MMM dd HH:mm:ss zzz uuuu", Locale.US).parse(new Date().toString())


      Attachments

        Issue Links

          Activity

            People

              jpai Jaikiran Pai
              macarte Mat Carter
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: