Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49442
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 10 Jul 2010 21:22:12 +0000 (21:22 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 10 Jul 2010 21:22:12 +0000 (21:22 +0000)
Trivial code clean-up. No functional change.
Based on a patch provided by Sebb.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@962919 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/tomcat/util/res/StringManager.java

index 535ee2c..1cb9a6c 100644 (file)
@@ -55,8 +55,8 @@ public class StringManager {
     /**
      * The ResourceBundle for this StringManager.
      */
-    private ResourceBundle bundle;
-    private Locale locale;
+    private final ResourceBundle bundle;
+    private final Locale locale;
 
     /**
      * Creates a new StringManager for a given package. This is a
@@ -68,8 +68,9 @@ public class StringManager {
      */
     private StringManager(String packageName) {
         String bundleName = packageName + ".LocalStrings";
+        ResourceBundle bnd = null;
         try {
-            bundle = ResourceBundle.getBundle(bundleName, Locale.getDefault());
+            bnd = ResourceBundle.getBundle(bundleName, Locale.getDefault());
         } catch( MissingResourceException ex ) {
             // Try from the current loader (that's the case for trusted apps)
             // Should only be required if using a TC5 style classloader structure
@@ -77,16 +78,19 @@ public class StringManager {
             ClassLoader cl = Thread.currentThread().getContextClassLoader();
             if( cl != null ) {
                 try {
-                    bundle = ResourceBundle.getBundle(
+                    bnd = ResourceBundle.getBundle(
                             bundleName, Locale.getDefault(), cl);
                 } catch(MissingResourceException ex2) {
                     // Ignore
                 }
             }
         }
+        bundle = bnd;
         // Get the actual locale, which may be different from the requested one
         if (bundle != null) {
             locale = bundle.getLocale();
+        } else {
+            locale = null;
         }
     }
 
@@ -152,7 +156,7 @@ public class StringManager {
     // STATIC SUPPORT METHODS
     // --------------------------------------------------------------
 
-    private static Hashtable<String, StringManager> managers =
+    private static final Hashtable<String, StringManager> managers =
         new Hashtable<String, StringManager>();
 
     /**