[teiid-commits] teiid SVN: r4553 - in branches/7.7.x/common-core/src: test/java/org/teiid/core/util and 1 other directory.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Wed Feb 27 11:33:27 EST 2013
Author: jolee
Date: 2013-02-27 11:33:26 -0500 (Wed, 27 Feb 2013)
New Revision: 4553
Modified:
branches/7.7.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java
branches/7.7.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java
Log:
TEIID-2383: InputStreamReader throws MalformedInputException when handling multi-byte characters
Modified: branches/7.7.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java
===================================================================
--- branches/7.7.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java 2013-02-05 20:34:44 UTC (rev 4552)
+++ branches/7.7.x/common-core/src/main/java/org/teiid/core/util/InputStreamReader.java 2013-02-27 16:33:26 UTC (rev 4553)
@@ -74,6 +74,7 @@
}
while (!done && !cb.hasRemaining()) {
int read = 0;
+ int pos = bb.position();
while ((read = rbc.read(bb)) == 0) {
//blocking read
}
@@ -90,7 +91,7 @@
}
done = true;
}
- if (bb.position() != read) {
+ if (bb.position() != read + pos) {
bb.compact();
} else {
bb.clear();
Modified: branches/7.7.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java
===================================================================
--- branches/7.7.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java 2013-02-05 20:34:44 UTC (rev 4552)
+++ branches/7.7.x/common-core/src/test/java/org/teiid/core/util/TestInputStreamReader.java 2013-02-27 16:33:26 UTC (rev 4553)
@@ -7,7 +7,7 @@
import org.junit.Test;
- at SuppressWarnings("nls")
+ at SuppressWarnings({"nls","resource"})
public class TestInputStreamReader {
@Test public void testMultiByte() throws Exception {
@@ -15,4 +15,14 @@
assertEquals(80, isr.read());
assertEquals(250, isr.read());
}
+
+ @Test public void testMultiByte1() throws Exception {
+ InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(new byte[] {(byte)80, (byte)-61, (byte)-70, (byte)-61, (byte)-70, (byte)80, (byte)-61, (byte)-70}), Charset.forName("UTF-8").newDecoder(), 4);
+ int count = 0;
+ while (isr.read() != -1) {
+ count++;
+ }
+ assertEquals(5, count);
+ }
+
}
More information about the teiid-commits
mailing list