Skip to content

ICU-23309 Add ClassLoader to caching key in ResourceBundleWrapper#3843

Open
own-mind wants to merge 1 commit intounicode-org:mainfrom
own-mind:fix-resource-bundle-wrapper-caching
Open

ICU-23309 Add ClassLoader to caching key in ResourceBundleWrapper#3843
own-mind wants to merge 1 commit intounicode-org:mainfrom
own-mind:fix-resource-bundle-wrapper-caching

Conversation

@own-mind
Copy link

@own-mind own-mind commented Jan 14, 2026

When using UResourceBundle.getBundleInstance(baseName, locale, classloader), in cases when RootType of the bundles is RootType.JAVA (for example, .property bundles), ResourceBundleWrapper is used as implementation for UResourceBundle. The classloader is provided to tell the implementation where to get the resources for the bundle.

However, the caching used in ResourceBundleWrapper for caching already discovered bundles does not respect the used classloader for those bundles, only the base name. Thus, if there are multiple bundles are requested with the same base name but different classloader, only the first discovered will be returned.

Changes made:

  • BundleCacheKey class was added that stores baseName and classLoader to be used in ResourceBundleWrapper.BUNDLE_CACHE instead of String key (that only reflected the baseName)

Checklist

  • Required: Issue filed: ICU-23309
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-NNNNN Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable
  • Approver: Feel free to merge on my behalf

@CLAassistant
Copy link

CLAassistant commented Jan 14, 2026

CLA assistant check
All committers have signed the CLA.

@markusicu markusicu self-requested a review January 15, 2026 17:39
@own-mind own-mind force-pushed the fix-resource-bundle-wrapper-caching branch from d32a296 to 25ca1e8 Compare January 16, 2026 15:44
@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • icu4j/main/core/src/main/java/com/ibm/icu/impl/LocaleFallbackData.java is now changed in the branch
  • icu4j/main/core/src/main/java/com/ibm/icu/impl/ResourceBundleWrapper.java is different
  • icu4j/main/core/src/test/java/com/ibm/icu/dev/test/impl/ResourceBundleWrapperCachingTest.java is different
  • icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java is now changed in the branch
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/first/localization_de.properties is different
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/first/localization.properties is different
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/second/localization_de.properties is different
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/second/localization.properties is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

Copy link
Contributor

@mihnita mihnita left a comment

Choose a reason for hiding this comment

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

I have a few nitpicks, nothing big.
Thank you!
Mihai

Copy link
Contributor

Choose a reason for hiding this comment

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

This file is generated.
So these changes will be lost next time.

I would say don't touch this file.
It is not related to anything this PR is doing.
It is not your problem to solve :-)

And if you want to solve it, great, I appreciate it!
But it would be in a different PR, and would also update the generator.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why reformat this file?

I know it is enforced now.
But I don't see any changes relevant to this PR.
So there is no need to reformat if it is not part of the PR.
If there are changes that are PR related then I don't see them
(one of the reasons we usually ask for these kind of changes to have 2 commits, one with change proper and one with the re-formatting.

Too late now...
But tldr:

  • if there is a change here that is related to the PR, then please help me see it, because I can't find it
  • if there is nothing PR related then just drop the file

Copy link
Author

Choose a reason for hiding this comment

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

I have force-pushed the fixes, now without those extra files. I was complying with PR checks regarding formatting and single-commit, but I guess those checks aren't as important :)

@own-mind own-mind force-pushed the fix-resource-bundle-wrapper-caching branch from 25ca1e8 to 8c2dd91 Compare January 29, 2026 22:41
@jira-pull-request-webhook
Copy link

Notice: the branch changed across the force-push!

  • icu4j/main/core/src/main/java/com/ibm/icu/impl/LocaleFallbackData.java is no longer changed in the branch
  • icu4j/main/core/src/main/java/com/ibm/icu/impl/ResourceBundleWrapper.java is different
  • icu4j/main/core/src/test/java/com/ibm/icu/dev/test/util/DebugUtilitiesData.java is no longer changed in the branch
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/first/localization_de.properties is different
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/first/localization.properties is different
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/second/localization_de.properties is different
  • icu4j/main/core/src/test/resources/com/ibm/icu/dev/test/locale/second/localization.properties is different

View Diff Across Force-Push

~ Your Friendly Jira-GitHub PR Checker Bot

@own-mind own-mind requested a review from mihnita January 29, 2026 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants