Fixing BufferedReader test regressions caused by r835212.
For the curious, some background on the tests that were broken:
- BufferedReaderTest.test_read_$CII_Exception: this is a straight up regression in exception priorities. I've submitted the fix.
- BufferedReaderTest.test_reset_IOException: this test is bogus. It expects reset() to fail after the end of stream has been reached, which is not specified behaviour. I've fixed the test.
git-svn-id: https://svn.apache.org/repos/asf/harmony/enhanced/classlib/trunk@835954 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/modules/luni/src/main/java/java/io/BufferedReader.java b/modules/luni/src/main/java/java/io/BufferedReader.java
index 473c386..1ead6b5 100644
--- a/modules/luni/src/main/java/java/io/BufferedReader.java
+++ b/modules/luni/src/main/java/java/io/BufferedReader.java
@@ -278,11 +278,8 @@
if (isClosed()) {
throw new IOException(Msg.getString("K005b")); //$NON-NLS-1$
}
- if (buffer == null) {
- throw new NullPointerException(Msg.getString("K0047")); //$NON-NLS-1$
- }
- if ((offset | length) < 0 || offset > buffer.length - length) {
- throw new IndexOutOfBoundsException(Msg.getString("K002f")); //$NON-NLS-1$
+ if (offset < 0 || offset > buffer.length - length || length < 0) {
+ throw new IndexOutOfBoundsException();
}
int outstanding = length;
while (outstanding > 0) {
diff --git a/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java b/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java
index 6764841..6f0ef40 100644
--- a/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java
+++ b/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedReaderTest.java
@@ -528,8 +528,8 @@
public void test_reset_IOException() throws Exception {
int[] expected = new int[] { '1', '2', '3', '4', '5', '6', '7', '8',
'9', '0', -1 };
- br = new BufferedReader(new Support_StringReader("1234567890"));
- br.mark(10);
+ br = new BufferedReader(new Support_StringReader("1234567890"), 9);
+ br.mark(9);
for (int i = 0; i < 11; i++) {
assertEquals(expected[i], br.read());
}