harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r424890 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/io/BufferedInputStream.java test/java/tests/api/java/io/BufferedInputStreamTest.java
Date Mon, 24 Jul 2006 03:29:14 GMT
Author: pyang
Date: Sun Jul 23 20:29:14 2006
New Revision: 424890

URL: http://svn.apache.org/viewvc?rev=424890&view=rev
Log:
Fix for HARMONY-667 ( [classlib][io]java.io.BufferedInputStream.skip(int n) unexpected NPE)

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=424890&r1=424889&r2=424890&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
Sun Jul 23 20:29:14 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 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.
@@ -109,6 +109,9 @@
 	 *             If an error occurs attempting to close this stream.
 	 */
 	public synchronized void close() throws IOException {
+        if(null == in){
+            throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0059"));
+        }
 		super.close();
 		buf = null;
 	}
@@ -311,6 +314,9 @@
 	 *             occurs.
 	 */
 	public synchronized long skip(long amount) throws IOException {
+        if(null == in){
+            throw new IOException(org.apache.harmony.luni.util.Msg.getString("K0059"));
+        }
 		if (amount < 1)
 			return 0;
 

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=424890&r1=424889&r2=424890&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
Sun Jul 23 20:29:14 2006
@@ -1,4 +1,4 @@
-/* Copyright 1998, 2005 The Apache Software Foundation or its licensors, as applicable
+/* Copyright 1998, 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.
@@ -120,6 +120,14 @@
 		// Test for method void java.io.BufferedInputStream.close()
 		new BufferedInputStream(isFile);
 		new BufferedInputStream(isFile);
+		
+		//regression for HARMONY-667
+        BufferedInputStream buf = new BufferedInputStream(null, 5);
+        try {
+            buf.close();
+        } catch (IOException e) {
+            //expected
+        }                         
 	}
 
 	/**
@@ -310,6 +318,14 @@
 		} catch (java.io.IOException e) {
 			fail("Exception during skip test");
 		}
+
+		//regression for HARMONY-667
+        BufferedInputStream buf = new BufferedInputStream(null, 5);
+        try {
+            buf.skip(10);
+        } catch (IOException e) {
+            //expected
+        }                         
 	}
 
 	/**



Mime
View raw message