]> granicus.if.org Git - icu/commitdiff
ICU-8630 Follow up fix - ULocale#setDefault(ULocale) to synchronize default Locale...
authorYoshito Umaoka <y.umaoka@gmail.com>
Fri, 19 Aug 2011 20:44:12 +0000 (20:44 +0000)
committerYoshito Umaoka <y.umaoka@gmail.com>
Fri, 19 Aug 2011 20:44:12 +0000 (20:44 +0000)
X-SVN-Rev: 30549

icu4j/main/classes/core/src/com/ibm/icu/util/ULocale.java
icu4j/main/tests/core/src/com/ibm/icu/dev/test/util/ULocaleTest.java

index b40d2d7f605a1cc99f0fcadc3a800c07f2e94bf6..da95103639ea9810c1830d43c7db13fdd2b3ed21 100644 (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()) {
index e43db6597256be0f7787d7dad27cb3bb0abc2de0..726e8e8d036e023932438faaaa809e86a8c9d05c 100644 (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 =================