harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r375577 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/ test/java/org/apache/harmony/tests/java/io/
Date Tue, 07 Feb 2006 11:24:22 GMT
Author: tellison
Date: Tue Feb  7 03:24:17 2006
New Revision: 375577

URL: http://svn.apache.org/viewcvs?rev=375577&view=rev
Log:
Fix for HARMONY-49 (java.io.PushBackInputStream throws ArrayIndexOutOfBoundsException instead
of IOException)

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/PushBackInputStreamTest.java
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackInputStream.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackReader.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackInputStream.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackInputStream.java?rev=375577&r1=375576&r2=375577&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackInputStream.java
Tue Feb  7 03:24:17 2006
@@ -260,6 +260,9 @@
 	 */
 	public void unread(byte[] buffer, int offset, int length)
 			throws IOException {
+		if (length > pos)
+			// Pushback buffer full
+			throw new IOException(com.ibm.oti.util.Msg.getString("K007e"));
 		// avoid int overflow
 		if (0 <= offset && offset <= buffer.length && 0 <= length
 				&& length <= buffer.length - offset) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackReader.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackReader.java?rev=375577&r1=375576&r2=375577&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackReader.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/PushbackReader.java
Tue Feb  7 03:24:17 2006
@@ -267,6 +267,9 @@
 	 *             If the pushback buffer becomes, or is, full.
 	 */
 	public void unread(char[] buffer, int offset, int count) throws IOException {
+		if (count > pos)
+			// Pushback buffer full
+			throw new IOException(com.ibm.oti.util.Msg.getString("K007e"));
 		// avoid int overflow
 		if (0 <= offset && offset <= buffer.length && 0 <= count
 				&& count <= buffer.length - offset) {

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java?rev=375577&r1=375576&r2=375577&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/AllTests.java
Tue Feb  7 03:24:17 2006
@@ -29,6 +29,7 @@
 				"Test for org.apache.harmony.tests.java.io");
 		//$JUnit-BEGIN$
 		suite.addTestSuite(FileTest.class);
+		suite.addTestSuite(PushBackInputStreamTest.class);
 		//$JUnit-END$
 		return suite;
 	}

Added: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/PushBackInputStreamTest.java
URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/PushBackInputStreamTest.java?rev=375577&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/PushBackInputStreamTest.java
(added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/io/PushBackInputStreamTest.java
Tue Feb  7 03:24:17 2006
@@ -0,0 +1,40 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.harmony.tests.java.io;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.PushbackInputStream;
+
+import junit.framework.TestCase;
+
+public class PushBackInputStreamTest extends TestCase {
+
+	/**
+	 * @tests java.io.PushbackInputStream#unread(byte[], int, int)
+	 */
+	public void test_unread$BII() {
+		// Regression for HARMONY-49
+		try {
+			PushbackInputStream pb = new PushbackInputStream(
+					new ByteArrayInputStream(new byte[] { 0 }), 2);
+			pb.unread(new byte[1], 0, 5);
+			fail("Assert 0: should throw IOE");
+		} catch (IOException e) {
+			// expected
+		}
+	}
+}



Mime
View raw message