From: markt Date: Sat, 10 Jul 2010 21:22:12 +0000 (+0000) Subject: Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49442 X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c810f1c6b6e9f9fa3713f25894473aad787b7437;p=tomcat7.0 Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=49442 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 --- diff --git a/java/org/apache/tomcat/util/res/StringManager.java b/java/org/apache/tomcat/util/res/StringManager.java index 535ee2ca5..1cb9a6c44 100644 --- a/java/org/apache/tomcat/util/res/StringManager.java +++ b/java/org/apache/tomcat/util/res/StringManager.java @@ -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 managers = + private static final Hashtable managers = new Hashtable(); /**