harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From regi...@apache.org
Subject svn commit: r962400 - in /harmony/enhanced/java/trunk/classlib/modules/luni/src: main/java/java/io/BufferedOutputStream.java test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java
Date Fri, 09 Jul 2010 04:30:01 GMT
Author: regisxu
Date: Fri Jul  9 04:30:01 2010
New Revision: 962400

URL: http://svn.apache.org/viewvc?rev=962400&view=rev
Log:
Apply patch for HARMONY-6570: [classlib][luni] BufferedOutputStream.write throws IOE

Modified:
    harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/io/BufferedOutputStream.java
    harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/io/BufferedOutputStream.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/io/BufferedOutputStream.java?rev=962400&r1=962399&r2=962400&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/io/BufferedOutputStream.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/main/java/java/io/BufferedOutputStream.java
Fri Jul  9 04:30:01 2010
@@ -121,8 +121,11 @@ public class BufferedOutputStream extend
     public synchronized void write(byte[] buffer, int offset, int length)
             throws IOException {
         byte[] internalBuffer = buf;
-        if (internalBuffer == null) {
-            throw new IOException(Messages.getString("luni.24")); //$NON-NLS-1$
+
+        if (internalBuffer != null && length >= internalBuffer.length) {
+            flushInternal();
+            out.write(buffer, offset, length);
+            return;
         }
 
         if (buffer == null) {
@@ -130,12 +133,6 @@ public class BufferedOutputStream extend
             throw new NullPointerException(Messages.getString("luni.11")); //$NON-NLS-1$
         }
         
-        if (length >= internalBuffer.length) {
-            flushInternal();
-            out.write(buffer, offset, length);
-            return;
-        }
-        
         if (offset < 0 || offset > buffer.length - length) {
             // luni.12=Offset out of bounds \: {0}
             throw new ArrayIndexOutOfBoundsException(Messages.getString("luni.12", offset));
//$NON-NLS-1$
@@ -146,6 +143,10 @@ public class BufferedOutputStream extend
             throw new ArrayIndexOutOfBoundsException(Messages.getString("luni.18", length));
//$NON-NLS-1$
         }
 
+        if (internalBuffer == null) {
+            throw new IOException(Messages.getString("luni.24")); //$NON-NLS-1$
+        }
+
         // flush the internal buffer first if we have not enough space left
         if (length >= (internalBuffer.length - count)) {
             flushInternal();

Modified: harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java?rev=962400&r1=962399&r2=962400&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/io/BufferedOutputStreamTest.java
Fri Jul  9 04:30:01 2010
@@ -329,8 +329,22 @@ public class BufferedOutputStreamTest ex
         try {
             bos.write(byteArray, -1, -1);
             fail();
-        } catch (Exception e) {
-            // expected IOException. RI throws IndexOutOfBoundsException
+        } catch (IndexOutOfBoundsException e) {
+            // expected IndexOutOfBoundsException
+        }
+
+        try {
+            bos.write(null, -1, -1);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected NullPointerException.
+        }
+
+        try {
+            bos.write(null, 0, 1);
+            fail("should throw NullPointerException");
+        } catch (NullPointerException e) {
+            // expected NullPointerException.
         }
     }
 



Mime
View raw message