harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r923557 - /harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
Date Tue, 16 Mar 2010 02:56:37 GMT
Author: regisxu
Date: Tue Mar 16 02:56:37 2010
New Revision: 923557

URL: http://svn.apache.org/viewvc?rev=923557&view=rev
Log:
Apply patch for HARMONY-6461: [classlib][nio_char]Remove alias cache from Charset

Modified:
    harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java?rev=923557&r1=923556&r2=923557&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
Tue Mar 16 02:56:37 2010
@@ -321,11 +321,6 @@ public abstract class Charset implements
      */
     @SuppressWarnings("unchecked")
     public static SortedMap<String, Charset> availableCharsets() {
-        // workaround: conflicted Charsets with icu4j 4.0
-        Charset.forName("TIS-620");
-        Charset.forName("windows-1258");
-        Charset.forName("cp856");
-        Charset.forName("cp922");
         // Initialize the built-in charsets map cache if necessary
         if (null == _builtInCharsets) {
             synchronized (Charset.class) {
@@ -448,7 +443,7 @@ public abstract class Charset implements
         }
         cs = _builtInProvider.charsetForName(charsetName);
         if (null != cs) {
-            cacheCharset(cs);
+            cacheCharset(cs, charsetName);
             return cs;
         }
 
@@ -477,7 +472,7 @@ public abstract class Charset implements
                         e.nextElement());
 				 inForNameInternal = false;
                 if (null != cs) {
-                    cacheCharset(cs);
+                    cacheCharset(cs, charsetName);
                     return cs;
                 }
             }
@@ -492,18 +487,15 @@ public abstract class Charset implements
     /*
      * save charset into cachedCharsetTable
      */
-    private static void cacheCharset(Charset cs) {
-        if (!cachedCharsetTable.containsKey(cs.name())){
-            cachedCharsetTable.put(cs.name(), cs);
-        }
-        Set<String> aliasesSet = cs.aliases();
-        if (null != aliasesSet) {
-            Iterator<String> iter = aliasesSet.iterator();
-            while (iter.hasNext()) {
-                String alias = iter.next();
-                if (!cachedCharsetTable.containsKey(alias)) {
-                    cachedCharsetTable.put(alias, cs);
-                }
+    private static void cacheCharset(Charset cs, String charsetName) {
+        String canonicalName = cs.name();
+        if (!cachedCharsetTable.containsKey(canonicalName)) {
+            cachedCharsetTable.put(canonicalName, cs);
+        }
+
+        if (!canonicalName.equals(charsetName)) {
+            if (!cachedCharsetTable.containsKey(charsetName)) {
+                cachedCharsetTable.put(charsetName, cs);
             }
         }
     }
@@ -554,7 +546,7 @@ public abstract class Charset implements
             }
             cs = _builtInProvider.charsetForName(charsetName);
             if (null != cs) {
-                cacheCharset(cs);
+                cacheCharset(cs, charsetName);
                 return true;
             }
             return false;



Mime
View raw message