-
Bug
-
Resolution: Fixed
-
P4
-
18
-
default Locale = en_CA
Windows and Mac
-
b12
-
generic
-
generic
-
Verified
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())
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())
- duplicates
-
JDK-8282173 Properties date tests can fail due to use of conflicting locale
-
- Closed
-
- relates to
-
JDK-8231640 (prop) Canonical property storage
-
- Resolved
-
- links to
-
Commit openjdk/jdk/e4d9fc81
-
Review openjdk/jdk/7558
-
Review(master) openjdk/jdk/7558