View | Details | Raw Unified | Return to bug 46933
Collapse All | Expand All

(-)java/org/apache/tomcat/util/res/StringManager.java (-14 / +25 lines)
Lines 73-82 Link Here
73
    }
73
    }
74
74
75
    private StringManager(String packageName, Locale loc) {
75
    private StringManager(String packageName, Locale loc) {
76
        String bundleName = packageName + ".LocalStrings";
76
       this(ResourceBundle.getBundle( packageName + ".LocalStrings", loc));
77
        bundle = ResourceBundle.getBundle(bundleName, loc);
78
        // Get the actual locale, which may be different from the requested one
79
        locale = bundle.getLocale();
80
    }
77
    }
81
78
82
    private StringManager(ResourceBundle bundle )
79
    private StringManager(ResourceBundle bundle )
Lines 146-153 Link Here
146
    // STATIC SUPPORT METHODS
143
    // STATIC SUPPORT METHODS
147
    // --------------------------------------------------------------
144
    // --------------------------------------------------------------
148
145
149
    private static Hashtable<String, StringManager> managers =
146
    private static Hashtable<String,ResourceBundle > managerMapper =
150
        new Hashtable<String, StringManager>();
147
        new Hashtable<String, ResourceBundle>();
148
    private static Hashtable<ResourceBundle, StringManager> managers =
149
        new Hashtable<ResourceBundle, StringManager>();
151
150
152
    /**
151
    /**
153
     * Get the StringManager for a particular package. If a manager for
152
     * Get the StringManager for a particular package. If a manager for
Lines 157-166 Link Here
157
     * @param packageName The package name
156
     * @param packageName The package name
158
     */
157
     */
159
    public synchronized static StringManager getManager(String packageName) {
158
    public synchronized static StringManager getManager(String packageName) {
160
      StringManager mgr = managers.get(packageName);
159
    	ResourceBundle rc = managerMapper.get(packageName);
160
        StringManager mgr = rc == null ? null : managers.get(rc);
161
      if (mgr == null) {
161
      if (mgr == null) {
162
          mgr = new StringManager(packageName);
162
          mgr = new StringManager(packageName);
163
          managers.put(packageName, mgr);
163
          rc = mgr.bundle;
164
          managers.put(rc, mgr);
165
          managerMapper.put(packageName, rc);
164
      }
166
      }
165
      return mgr;
167
      return mgr;
166
    }
168
    }
Lines 173-179 Link Here
173
     * @param bundle The resource bundle
175
     * @param bundle The resource bundle
174
     */
176
     */
175
    public synchronized static StringManager getManager(ResourceBundle bundle) {
177
    public synchronized static StringManager getManager(ResourceBundle bundle) {
176
      return new StringManager( bundle );
178
    	StringManager mgr = managers.get(bundle);
179
        if (mgr == null) {
180
            mgr = new StringManager(bundle);
181
            managers.put(bundle, mgr);
182
        }
183
        return mgr;
177
    }
184
    }
178
185
179
    /**
186
    /**
Lines 186-197 Link Here
186
     */
193
     */
187
194
188
   public synchronized static StringManager getManager(String packageName,Locale loc) {
195
   public synchronized static StringManager getManager(String packageName,Locale loc) {
189
      StringManager mgr = managers.get(packageName+"_"+loc.toString());
196
       String key = packageName+"_"+loc.toString();
190
      if (mgr == null) {
197
       ResourceBundle rc = managerMapper.get(key);
198
       StringManager mgr = rc == null ? null: managers.get(rc);
199
       if (mgr == null) {
191
          mgr = new StringManager(packageName,loc);
200
          mgr = new StringManager(packageName,loc);
192
          managers.put(packageName+"_"+loc.toString(), mgr);
201
          rc = mgr.bundle;
193
      }
202
          managers.put(rc, mgr);
194
      return mgr;
203
          managerMapper.put(key, rc);
204
       }
205
       return mgr;
195
    }
206
    }
196
207
197
}
208
}

Return to bug 46933