harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r806001 - in /harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset: Charset.java CharsetEncoder.java
Date Wed, 19 Aug 2009 22:39:32 GMT
Author: hindessm
Date: Wed Aug 19 22:39:31 2009
New Revision: 806001

URL: http://svn.apache.org/viewvc?rev=806001&view=rev
Log:
Apply trivial part of patch for "[#HARMONY-6312] Concurrency problems in
NIO" - making java.nio.charset.Charset.isSupported(String) synchronized
and minor whitespace improvements.

Modified:
    harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/Charset.java
    harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.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=806001&r1=806000&r2=806001&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
Wed Aug 19 22:39:31 2009
@@ -483,7 +483,7 @@
             }
         } catch (IOException ex) {
             // Unexpected ClassLoader exception, ignore
-		} finally {
+        } finally {
 		    inForNameInternal = false;
         }
         return null;
@@ -494,7 +494,7 @@
      */
     private static void cacheCharset(Charset cs) {
         if (!cachedCharsetTable.containsKey(cs.name())){
-            cachedCharsetTable.put(cs.name(), cs);  
+            cachedCharsetTable.put(cs.name(), cs);
         }
         Set<String> aliasesSet = cs.aliases();
         if (null != aliasesSet) {
@@ -502,7 +502,7 @@
             while (iter.hasNext()) {
                 String alias = iter.next();
                 if (!cachedCharsetTable.containsKey(alias)) {
-                    cachedCharsetTable.put(alias, cs); 
+                    cachedCharsetTable.put(alias, cs);
                 }
             }
         }
@@ -536,8 +536,8 @@
      * @throws IllegalCharsetNameException
      *             if the specified charset name is illegal.
      */
-    public static boolean isSupported(String charsetName) {
-        if (inForNameInternal  == true) {
+    public static synchronized boolean isSupported(String charsetName) {
+        if (inForNameInternal) {
             Charset cs = cachedCharsetTable.get(charsetName);
             if (null != cs) {
                 return true;

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java?rev=806001&r1=806000&r2=806001&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
Wed Aug 19 22:39:31 2009
@@ -339,12 +339,12 @@
                 continue;
             }
             checkCoderResult(result);
-        output.flip();
-        if (result.isMalformed()) {
-            throw new MalformedInputException(result.length());
-        } else if (result.isUnmappable()) {
-            throw new UnmappableCharacterException(result.length());
-        }
+            output.flip();
+            if (result.isMalformed()) {
+                throw new MalformedInputException(result.length());
+            } else if (result.isUnmappable()) {
+                throw new UnmappableCharacterException(result.length());
+            }
             break;
         }
         status = FLUSH;
@@ -451,18 +451,18 @@
             } catch (BufferUnderflowException e) {
                 throw new CoderMalfunctionError(e);
             }
-            if (result==CoderResult.UNDERFLOW) {
+            if (result == CoderResult.UNDERFLOW) {
                 status = endOfInput ? END : ONGOING;
                 if (endOfInput) {
                     int remaining = in.remaining();
-                    if( remaining > 0) {
-                    result = CoderResult.malformedForLength(remaining);
+                    if (remaining > 0) {
+                        result = CoderResult.malformedForLength(remaining);
+                    } else {
+                        return result;
+                    }
                 } else {
                     return result;
                 }
-                } else {
-                    return result;
-            }
             } else if (result==CoderResult.OVERFLOW) {
                 status = endOfInput ? END : ONGOING;
                 return result;



Mime
View raw message