]> granicus.if.org Git - icu/commitdiff
ICU-8620 remove static ICUResourceBundle.cache
authorDoug Felt <dougfelt@gmail.com>
Fri, 3 Jun 2011 23:17:53 +0000 (23:17 +0000)
committerDoug Felt <dougfelt@gmail.com>
Fri, 3 Jun 2011 23:17:53 +0000 (23:17 +0000)
X-SVN-Rev: 30195

icu4j/main/classes/core/src/com/ibm/icu/impl/ICUResourceBundle.java

index 5cc12fecb0eeb7407ce3e4a67aa376506b337e9a..50d915b71fcb1f8f780b66de6c113308b59a546a 100644 (file)
@@ -26,7 +26,6 @@ import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.StringTokenizer;
-import java.util.concurrent.ConcurrentHashMap;
 
 import com.ibm.icu.impl.URLHandler.URLVisitor;
 import com.ibm.icu.util.ULocale;
@@ -995,42 +994,21 @@ public  class ICUResourceBundle extends UResourceBundle {
      */
     public static final int ARRAY16 = 9;
 
-    private static final ConcurrentHashMap<String, ICUResourceBundle> cache = 
-        new ConcurrentHashMap<String, ICUResourceBundle>();
-    private static final ICUResourceBundle NULL_BUNDLE = 
-        new ICUResourceBundle(null, null, null, 0, null) {
-        public int hashCode() {
-            return 0;
-        }
-        public boolean equals(Object rhs) {
-            return this == rhs;
-        }
-    };
-    
    /**
-    *
+    * Create a bundle using a reader.
     * @param baseName The name for the bundle.
     * @param localeID The locale identification.
     * @param root The ClassLoader object root.
     * @return the new bundle
     */
-    public static ICUResourceBundle createBundle(String baseName, String localeID, 
-            ClassLoader root) {
-        
-        String resKey = Integer.toHexString(root.hashCode()) + baseName + localeID;
-        ICUResourceBundle b = cache.get(resKey);
-        if (b == null) {
-            String resolvedName = getFullName(baseName, localeID);
-            ICUResourceBundleReader reader = ICUResourceBundleReader.getReader(resolvedName, root);
-            // could not open the .res file so return null
-            if (reader == null) {
-                b = NULL_BUNDLE;
-            } else {
-                b = getBundle(reader, baseName, localeID, root);
-            }
-            cache.put(resKey, b);
+    public static ICUResourceBundle createBundle(String baseName, String localeID, ClassLoader root) {
+        String resolvedName = getFullName(baseName, localeID);
+        ICUResourceBundleReader reader = ICUResourceBundleReader.getReader(resolvedName, root);
+        if (reader == null) {
+            // could not open the .res file
+            return null;
         }
-        return b == NULL_BUNDLE ? null : b;
+        return getBundle(reader, baseName, localeID, root);
     }
 
     protected String getLocaleID() {
@@ -1284,7 +1262,7 @@ public  class ICUResourceBundle extends UResourceBundle {
         if (lookup != null) {
             indexKey = Integer.valueOf(index);
             res = lookup.get(indexKey);
-        }
+        } 
         if (res == null) {
             boolean[] alias = new boolean[1];
             res = handleGetImpl(index, table, requested, alias);