ICU-8630 Follow up fix - ULocale#setDefault(ULocale) to synchronize default Locale properly.

X-SVN-Rev: 30549
This commit is contained in:
Yoshito Umaoka 2011-08-19 20:44:12 +00:00
parent 3ca1e00e84
commit 02375bb109
2 changed files with 8 additions and 1 deletions

View file

@ -597,7 +597,8 @@ public final class ULocale implements Serializable {
* @stable ICU 3.0
*/
public static synchronized void setDefault(ULocale newLocale){
Locale.setDefault(newLocale.toLocale());
defaultLocale = newLocale.toLocale();
Locale.setDefault(defaultLocale);
defaultULocale = newLocale;
// This method also updates all category default locales
for (Category cat : Category.values()) {

View file

@ -194,6 +194,7 @@ public class ULocaleTest extends TestFmwk {
*/
public void TestJavaLocaleCompatibility() {
Locale backupDefault = Locale.getDefault();
ULocale orgUlocDefault = ULocale.getDefault();
// Java Locale for ja_JP with Japanese calendar
Locale jaJPJP = new Locale("ja", "JP", "JP");
@ -289,6 +290,11 @@ public class ULocaleTest extends TestFmwk {
errln("FAIL: ULocale#setDefault failed to set Java Locale no_NO_NY /actual: " + Locale.getDefault());
}
Locale.setDefault(backupDefault);
// Make sure default ULocale is restored
if (!ULocale.getDefault().equals(orgUlocDefault)) {
errln("FAIL: Original default ULocale is not restored - " + ULocale.getDefault() + ", expected(orginal) - " + orgUlocDefault);
}
}
// ================= Infrastructure =================