Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4318520

Regression - ResourceBundle.getBundle caching fails when default locale changes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.3.0
    • core-libs
    • None
    • merlin
    • generic
    • generic



      Name: nl37777 Date: 03/02/2000


      ResourceBundle.getResourceBundle caches the bundle found for a given
      name and
      locale. Sometimes the bundle found depends on the current value of
      Locale.getDefault(). When the system default locale changes however,
      the cache
      is not invalidated.


      import java.util.ResourceBundle;
      import java.util.Locale;

      public class Test4022389 {

          public static void main(String[] args) {
              test(Locale.GERMAN);
              test(Locale.ENGLISH);
          }

          private static void test(Locale locale) {
              Locale.setDefault(locale);
              ResourceBundle myResources =
                      ResourceBundle.getBundle("RB", Locale.FRENCH);
              String actualLocale = myResources.getString("name");
              if (!actualLocale.equals(locale.toString())) {
                  System.out.println("expected: " + locale +
                           ", got: " + actualLocale);
                  throw new RuntimeException();
              }
          }
      }

      Content of RB_de.properties:
      name=de

      Content of RB_en.properties:
      name=en

      ======================================================================

            nlindenbsunw Norbert Lindenberg (Inactive)
            nlindenbsunw Norbert Lindenberg (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: