You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/07/24 08:28:10 UTC

svn commit: r424926 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/CharArrayReader.java test/java/tests/api/java/io/BufferedReaderTest.java

Author: pyang
Date: Sun Jul 23 23:28:10 2006
New Revision: 424926

URL: http://svn.apache.org/viewvc?rev=424926&view=rev
Log:
Fix for HARMONY-841 ([classlib][io] java.io.BufferedReader.read() throws unspesified ArrayIndexOutOfBoundsException)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java?rev=424926&r1=424925&r2=424926&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/CharArrayReader.java Sun Jul 23 23:28:10 2006
@@ -181,7 +181,7 @@
 				&& len <= buffer.length - offset) {
 			synchronized (lock) {
 				if (isOpen()) {
-					if (pos != this.count) {
+					if (pos < this.count) {
 						int bytesRead = pos + len > this.count ? this.count
 								- pos : len;
 						System.arraycopy(this.buf, pos, buffer, offset,

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java?rev=424926&r1=424925&r2=424926&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedReaderTest.java Sun Jul 23 23:28:10 2006
@@ -17,6 +17,7 @@
 
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
+import java.io.CharArrayReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PipedReader;
@@ -133,7 +134,7 @@
 	/**
 	 * @tests java.io.BufferedReader#read()
 	 */
-	public void test_read() {
+	public void test_read() throws IOException {
 		// Test for method int java.io.BufferedReader.read()
 		try {
 			br = new BufferedReader(new Support_StringReader(testString));
@@ -162,6 +163,9 @@
 		} catch (IOException e) {
 			fail("Exception during read test 2:" + e);
 		}
+		
+		// regression test for HARMONY-841
+		assertTrue(new BufferedReader(new CharArrayReader(new char[5], 1, 0), 2).read() == -1);
 	}
 
 	/**