harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mloe...@apache.org
Subject svn commit: r397106 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/InputStreamReader.java test/java/tests/api/java/io/InputStreamReaderTest.java
Date Wed, 26 Apr 2006 06:29:12 GMT
Author: mloenko
Date: Tue Apr 25 23:29:12 2006
New Revision: 397106

URL: http://svn.apache.org/viewcvs?rev=397106&view=rev
Log:
fix for HARMONY-411
InputStreamReader should not thrown exception if bytes sequence is incomplete

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java?rev=397106&r1=397105&r2=397106&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/InputStreamReader.java
Tue Apr 25 23:29:12 2006
@@ -21,6 +21,7 @@
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CoderResult;
+import java.nio.charset.CodingErrorAction;
 import java.security.AccessController;
 import java.util.HashMap;
 
@@ -87,7 +88,9 @@
 		enc.length();
 		this.in = in;
 		try {
-			decoder = Charset.forName(enc).newDecoder();
+			decoder = Charset.forName(enc).newDecoder()
+			          .onMalformedInput(CodingErrorAction.REPLACE)
+			          .onUnmappableCharacter(CodingErrorAction.REPLACE);
 		} catch (IllegalArgumentException e) {
 			throw new UnsupportedEncodingException();
 		}

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java?rev=397106&r1=397105&r2=397106&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/InputStreamReaderTest.java
Tue Apr 25 23:29:12 2006
@@ -151,6 +151,16 @@
 		assertEquals(-1, reader.read());
 	}
 
+    /*
+     * Class under test for int read()
+     * Regression for Harmony-411
+     */
+    public void testRead1() throws IOException {
+        InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(
+                new byte[] { -32, -96 }), "UTF-8");
+        assertEquals("read() return incorrect value", 65533, isr.read());
+    }
+
 	/*
 	 * Class under test for int read(char[], int, int)
 	 */



Mime
View raw message