Skip to content

8392223: CLDR provider mutates shared cached time zone name arrays - #32867

Closed
moseoh wants to merge 2 commits into
openjdk:masterfrom
moseoh:8392223-cldr-tz-shared-array
Closed

moseoh wants to merge 2 commits into
openjdk:masterfrom
moseoh:8392223-cldr-tz-shared-array

Conversation

@moseoh

@moseoh moseoh commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

CLDRTimeZoneNameProviderImpl.getDisplayNameArray() modifies the array
cached by LocaleResources when 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.

TimeZoneNameOrderTest compares a direct lookup with a lookup made after
querying the parent locale. The two runs use separate JVMs so that they
do not share cached state.

TimeZoneNameConcurrencyTest compares concurrent first lookups with
sequential 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

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

  • JDK-8392223: CLDR provider mutates shared cached time zone name arrays (Bug - P3)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/32867/head:pull/32867
$ git checkout pull/32867

Update a local copy of the PR:
$ git checkout pull/32867
$ git pull https://git.openjdk.org/jdk.git pull/32867/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 32867

View PR using the GUI difftool:
$ git pr show -t 32867

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/32867.diff

Using Webrev

Link to Webrev Comment

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.
@bridgekeeper bridgekeeper Bot added the oca Needs verification of OCA signatory status label Sep 15, 2026
@bridgekeeper

bridgekeeper Bot commented Sep 15, 2026

Copy link
Copy Markdown

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 /signed in a comment in this pull request.

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 /covered in a comment in this pull request.

@moseoh

moseoh commented Sep 15, 2026

Copy link
Copy Markdown
Contributor Author

/signed

@openjdk

openjdk Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

@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:

8392223: CLDR provider mutates shared cached time zone name arrays

Reviewed-by: naoto

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 master branch:

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 /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@bridgekeeper bridgekeeper Bot added the oca-verify Needs verification of OCA signatory status label Sep 15, 2026
@bridgekeeper

bridgekeeper Bot commented Sep 15, 2026

Copy link
Copy Markdown

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!

@openjdk

openjdk Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

@moseoh The following labels will be automatically applied to this pull request:

  • core-libs
  • i18n

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@bridgekeeper bridgekeeper Bot removed oca Needs verification of OCA signatory status oca-verify Needs verification of OCA signatory status labels Sep 22, 2026
@openjdk openjdk Bot added the rfr Pull request is ready for review label Sep 22, 2026
@mlbridge

mlbridge Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

Webrevs

@naotoj naotoj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix looks good.

ts[i] = new Thread(() -> {
try {
barrier.await();
tz.getDisplayName(false, TimeZone.SHORT, l);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, fixed. The test now checks each name returned by the worker threads.

@naotoj naotoj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for the changes.

Comment on lines +115 to +120
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);
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be removed as it is only called from a single location, but I am fine leaving it as it is

@openjdk openjdk Bot added the ready Pull request is ready to be integrated label Sep 24, 2026
@moseoh

moseoh commented Sep 25, 2026

Copy link
Copy Markdown
Contributor Author

/integrate

@openjdk openjdk Bot added the sponsor Pull request is ready to be sponsored label Sep 25, 2026
@openjdk

openjdk Bot commented Sep 25, 2026

Copy link
Copy Markdown

@moseoh
Your change (at version a239a70) is now ready to be sponsored by a Committer.

@naotoj

naotoj commented Sep 28, 2026

Copy link
Copy Markdown
Member

/sponsor

@openjdk

openjdk Bot commented Sep 28, 2026

Copy link
Copy Markdown

Going to push as commit d6c4fe7.
Since your change was applied there have been 236 commits pushed to the master branch:

Your commit was automatically rebased without conflicts.

@openjdk openjdk Bot added the integrated Pull request has been integrated label Sep 28, 2026
@openjdk openjdk Bot closed this Sep 28, 2026
@openjdk openjdk Bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review sponsor Pull request is ready to be sponsored labels Sep 28, 2026
@openjdk

openjdk Bot commented Sep 28, 2026

Copy link
Copy Markdown

@naotoj @moseoh Pushed as commit d6c4fe7.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@moseoh

moseoh commented Sep 29, 2026

Copy link
Copy Markdown
Contributor Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants