-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
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
======================================================================