Repository navigation
Conversation
CLDRTimeZoneNameProviderImpl.getDisplayNameArray() fixes up missing names in the array returned by LocaleResources.getTimeZoneNames(), which is the instance stored in the LocaleResources cache and handed to every caller. Derived values (last-resort GMT format, region format, COMPAT substitutions in the update releases) therefore end up in shared state. On mainline this makes a display name depend on lookup order: a value derived for a parent locale is inherited by a later child-locale lookup through the parent-locale check in deriveFallbackName() instead of being derived for the child. In 11u/17u/21u the same write races between threads on the first lookup and can replace a valid short name with a GMT offset for the life of the process. Copy the array before the fix-up so the cached instance stays pristine.
|
Hi @moseoh, welcome to this OpenJDK project and thanks for contributing! We do not recognize you as Contributor and need to ensure you have signed the Oracle Contributor Agreement (OCA). If you have not signed the OCA, please follow the instructions. Please fill in your GitHub username in the "Username" field of the application. Once you have signed the OCA, please let us know by writing If you already are an OpenJDK Author, Committer or Reviewer, please click here to open a new issue so that we can record that fact. Please use "Add GitHub user moseoh" as summary for the issue. If you are contributing this work on behalf of your employer and your employer has signed the OCA, please let us know by writing |
|
/signed |
|
@moseoh This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 198 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@naotoj) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
|
Thank you! Please allow for up to two weeks to process your OCA, although it is usually done within one to two business days. Also, please note that pull requests that are pending an OCA check will not usually be evaluated, so your patience is appreciated! |
Webrevs
|
| ts[i] = new Thread(() -> { | ||
| try { | ||
| barrier.await(); | ||
| tz.getDisplayName(false, TimeZone.SHORT, l); |
There was a problem hiding this comment.
I'd check the name returned by this tz.getDisplayName() call as well. The current code may miss cases where this call returns an inconsistent name.
There was a problem hiding this comment.
Good point, fixed. The test now checks each name returned by the worker threads.
| private static void printNames(TimeZone tz) { | ||
| String us = tz.getDisplayName(false, TimeZone.SHORT, Locale.US); | ||
| String en = tz.getDisplayName(false, TimeZone.SHORT, Locale.ENGLISH); | ||
| System.out.println(us); | ||
| System.out.println(en); | ||
| } |
There was a problem hiding this comment.
This could be removed as it is only called from a single location, but I am fine leaving it as it is
|
/integrate |
|
/sponsor |
|
Going to push as commit d6c4fe7.
Your commit was automatically rebased without conflicts. |
|
Thanks for the review and for sponsoring. Unless someone else already plans to, I'd like to do the backports to 21u, 17u and 11u once the fix has had some time in mainline. |
CLDRTimeZoneNameProviderImpl.getDisplayNameArray()modifies the arraycached by
LocaleResourceswhen filling in missing time zone names.As a result, names derived for a parent locale can be reused by a later
lookup for a child locale, making the result depend on lookup order.
This change copies the array before updating the zone ID and deriving
fallback names, leaving the cached array unchanged.
TimeZoneNameOrderTestcompares a direct lookup with a lookup made afterquerying the parent locale. The two runs use separate JVMs so that they
do not share cached state.
TimeZoneNameConcurrencyTestcompares concurrent first lookups withsequential lookups in a fresh JVM. It is included to cover the race seen
in 11u/17u/21u; it passes on mainline both before and after the fix.
Tested with jtreg sun/util, java/util/TimeZone and java/util/Locale on linux-x64.
Progress
Issue
Reviewers
Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32867/head:pull/32867$ git checkout pull/32867Update a local copy of the PR:
$ git checkout pull/32867$ git pull https://git.openjdk.org/jdk.git pull/32867/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 32867View PR using the GUI difftool:
$ git pr show -t 32867Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32867.diff
Using Webrev
Link to Webrev Comment