jdk/test/java/util/ResourceBundle/Bug6190861.java
changeset 10138 b7572da25d15
parent 5506 202f599c92aa
child 32649 2ee9017c7597
--- a/jdk/test/java/util/ResourceBundle/Bug6190861.java	Thu Jul 28 13:34:31 2011 -0700
+++ b/jdk/test/java/util/ResourceBundle/Bug6190861.java	Fri Jul 29 02:50:58 2011 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,27 +32,34 @@
 public class Bug6190861 {
 
     static public void main(String[] args) {
-        Locale.setDefault(new Locale("en", "US"));
+        Locale reservedLocale = Locale.getDefault();
+        try {
+            Locale.setDefault(new Locale("en", "US"));
 
-        List localeList = new ArrayList();
-        localeList.add(Locale.ENGLISH);
-        localeList.add(Locale.KOREA);
-        localeList.add(Locale.UK);
-        localeList.add(new Locale("en", "CA"));
-        localeList.add(Locale.ENGLISH);
+            List localeList = new ArrayList();
+            localeList.add(Locale.ENGLISH);
+            localeList.add(Locale.KOREA);
+            localeList.add(Locale.UK);
+            localeList.add(new Locale("en", "CA"));
+            localeList.add(Locale.ENGLISH);
 
-        Iterator iter = localeList.iterator();
-        while (iter.hasNext()){
-            Locale currentLocale = (Locale) iter.next();
-            System.out.println("\ncurrentLocale = "
+            Iterator iter = localeList.iterator();
+            while (iter.hasNext()){
+                Locale currentLocale = (Locale) iter.next();
+                System.out.println("\ncurrentLocale = "
                                + currentLocale.getDisplayName());
 
-            ResourceBundle messages = ResourceBundle.getBundle("Bug6190861Data",currentLocale);
+                ResourceBundle messages =
+                    ResourceBundle.getBundle("Bug6190861Data",currentLocale);
 
-            Locale messagesLocale = messages.getLocale();
-            System.out.println("messagesLocale = "
+                Locale messagesLocale = messages.getLocale();
+                System.out.println("messagesLocale = "
                                + messagesLocale.getDisplayName());
-            checkMessages(messages);
+                checkMessages(messages);
+            }
+        } finally {
+            // restore the reserved locale
+            Locale.setDefault(reservedLocale);
         }
     }