harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lian...@apache.org
Subject svn commit: r517635 - in /harmony/enhanced/classlib/trunk/modules/nio_char/src: main/java/java/nio/charset/CharsetEncoder.java test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
Date Tue, 13 Mar 2007 10:30:34 GMT
Author: liangyx
Date: Tue Mar 13 03:30:30 2007
New Revision: 517635

URL: http://svn.apache.org/viewvc?view=rev&rev=517635
Log:
Apply patch for HARMONY-3378([classlib][nio_char]IllegalStateException was thrown when encode
with malformed bytes.)

Modified:
    harmony/enhanced/classlib/trunk/modules/nio_char/src/main/java/java/nio/charset/CharsetEncoder.java
    harmony/enhanced/classlib/trunk/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java

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?view=diff&rev=517635&r1=517634&r2=517635
==============================================================================
--- 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
Tue Mar 13 03:30:30 2007
@@ -480,13 +480,12 @@
             }
             if (result.isUnderflow()) {
                 int remaining = in.remaining();
+                status = endOfInput ? END : ONGOING;
                 if (endOfInput && remaining > 0) {
                     result = CoderResult.malformedForLength(remaining);
                 } else {
-                    status = endOfInput ? END : ONGOING;
                     return result;
                 }
-
             }
             if (result.isOverflow()) {
                 return result;

Modified: harmony/enhanced/classlib/trunk/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java?view=diff&rev=517635&r1=517634&r2=517635
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/nio_char/src/test/java/tests/api/java/nio/charset/CharsetEncoderTest.java
Tue Mar 13 03:30:30 2007
@@ -556,6 +556,16 @@
 		out = encoder.encode(CharBuffer.wrap(unistr));
 		assertEquals(out.position(), 0);
 		assertByteArray(out, addSurrogate(unibytes));
+        
+        // Regression test for harmony-3378
+        Charset cs = Charset.forName("UTF-8");
+        CharsetEncoder encoder = cs.newEncoder();
+        encoder.onMalformedInput(CodingErrorAction.REPLACE);
+        encoder = encoder.replaceWith(new byte[] { (byte) 0xef, (byte) 0xbf,
+                (byte) 0xbd, });
+        CharBuffer in = CharBuffer.wrap("\ud800");
+        out = encoder.encode(in);
+        assertNotNull(out); 
 	}
 
 	private byte[] addSurrogate(byte[] expected) {



Mime
View raw message