harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r431548 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/BufferedInputStream.java test/java/tests/api/java/io/BufferedInputStreamTest.java
Date Tue, 15 Aug 2006 07:12:53 GMT
Author: pyang
Date: Tue Aug 15 00:12:52 2006
New Revision: 431548

URL: http://svn.apache.org/viewvc?rev=431548&view=rev
Log:
Patch applied for HARMONY-1165 ([classlib][luni] java.io.BufferedInputStream method reset()
throws different exceptions with RI)

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

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedInputStream.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedInputStream.java?rev=431548&r1=431547&r2=431548&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedInputStream.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/io/BufferedInputStream.java
Tue Aug 15 00:12:52 2006
@@ -90,7 +90,7 @@
     }
 
     /**
-     * Answers a int representing then number of bytes that are available before
+     * Answers an int representing the number of bytes that are available before
      * this BufferedInputStream will block. This method returns the number of
      * bytes available in the buffer plus those available in the target stream.
      * 
@@ -311,15 +311,13 @@
 
     @Override
     public synchronized void reset() throws IOException {
-        if (markpos != -1) {
-            if (buf != null) {
-                pos = markpos;
-            } else {
-                throw new IOException(Msg.getString("K0059")); //$NON-NLS-1$
-            }
-        } else {
-            throw new IOException(Msg.getString("K005a")); //$NON-NLS-1$
-        }
+    	if (closed) {
+    		throw new IOException(Msg.getString("K0059")); //$NON-NLS-1$	
+    	}
+        if (-1 == markpos) {
+        	throw new IOException(Msg.getString("K005a")); //$NON-NLS-1$
+        }    
+        pos = markpos;         
     }
 
     /**

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java?rev=431548&r1=431547&r2=431548&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java
Tue Aug 15 00:12:52 2006
@@ -345,6 +345,36 @@
 			fail("Exception during reset test");
 		}
 	}
+	
+    /**
+     * @tests java.io.BufferedInputStream#reset()
+	 */
+	public void test_reset_Exception() throws IOException {
+		BufferedInputStream bis = new BufferedInputStream(null);
+		
+		//throws IOExcepiton with message "Mark has been invalidated"
+		try {
+			bis.reset();
+			fail("should throw IOException");
+		} catch (IOException e) {
+			// expected
+		}
+		
+		//does not throw IOException
+		bis.mark(1);
+		bis.reset();
+		
+		bis.close();
+
+		//throws IOException with message "stream is closed"
+		try {
+			bis.reset();
+			fail("should throw IOException");
+		} catch (IOException e) {
+			// expected
+		}
+	}
+
 
 	/**
 	 * @tests java.io.BufferedInputStream#skip(long)



Mime
View raw message