JDK-8193496 : ResourceBundle caching bug for Nynorsk
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.util:i18n
  • Affected Version: 8,9,10
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: windows_7
  • CPU: x86_64
  • Submitted: 2017-12-12
  • Updated: 2018-09-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
tbdUnresolved
Description
FULL PRODUCT VERSION :
java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [Version 6.1.7601]

A DESCRIPTION OF THE PROBLEM :
Caching implemented in ResourceBundle (line 1328) causes that the wrong text is retrieved when caching applies for the special case no_NO_NY.

The candidate Locales for no_NO_NY are:
nn_NO
nn
no_NO_NY
no_NO
no

However, once the bundle for no_NO_NY is cached, then no longer a text from nn_NO is used but the one from no_NO_NY straight away. 
Most likely this has not caused any harm so far, since it is more of a theoretical Problem (one most probably does not define e.g. a properties file for both nn_NO and no_NO_NY).

Nevertheless, IMO it should be a documented behaviour. 

As consequence, I do no longer support no neither no_NO in my application.

STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
- create a bundle for nn_NO and one for no_NO_NY
- search for a corresponding property which exists in nn_NO => translation of nn_NO is returned
- search for it a second time => translation of no_NO_NY is returned

EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
translation of nn_NO is returned twice
ACTUAL -
translation of no_NO_NY is returned

REPRODUCIBILITY :
This bug can be reproduced always.

CUSTOMER SUBMITTED WORKAROUND :
Only define one properties file


Comments
Adding special case would resolve this issue (replacing no_NO_NY to nn_NO on getBundle()).
10-01-2018

The issue is reproducible using the attached test case in : JDK 8u151 - Fail JDK 9.0.1 +11 - fail JDK 10-ea+37 - Fail Exception in thread "main" java.lang.AssertionError at JI9051873.main(JI9051873.java:14)
10-01-2018

To submitter: I am not able to reproduce the issue stated in bug report. Attached is the test case and the two resource bundles I used. I am getting the same output (from resource bundle nn_NO ) as below on any number of runs: Hello In nn_NO say in nn_NO Hello In nn_NO Please let me know if you have any inputs that may help reproduce the issue. Please feel free to modify the test case if needed.
14-12-2017