You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2006/07/18 04:47:34 UTC

svn commit: r422946 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src: main/java/org/apache/harmony/nio/internal/FileChannelImpl.java test/java/common/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java

Author: pyang
Date: Mon Jul 17 19:47:33 2006
New Revision: 422946

URL: http://svn.apache.org/viewvc?rev=422946&view=rev
Log:
fix for HARMONY-902

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java?rev=422946&r1=422945&r2=422946&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/main/java/org/apache/harmony/nio/internal/FileChannelImpl.java Mon Jul 17 19:47:33 2006
@@ -311,10 +311,10 @@
         if (offset < 0 || length < 0 || offset + length > buffers.length) {
             throw new IndexOutOfBoundsException();
         }
+        openCheck();
         for (int i = offset; i < offset + length; i++) {
             count += buffers[i].remaining();
         }
-        openCheck();
         if (0 == count) {
             return 0;
         }

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java?rev=422946&r1=422945&r2=422946&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/common/org/apache/harmony/tests/java/nio/channels/FileChannelTest.java Mon Jul 17 19:47:33 2006
@@ -1372,6 +1372,27 @@
         } catch (ClosedChannelException e) {
             // expected
         }
+        
+        // regression test for Harmony-902
+        readBuffers[0] = null;
+        try {
+            readOnlyFileChannel.read(readBuffers, 0, 1);
+            fail("should throw ClosedChannelException");
+        } catch (ClosedChannelException e) {
+            // expected
+        }
+        try {
+            writeOnlyFileChannel.read(readBuffers, 0, 1);
+            fail("should throw ClosedChannelException");
+        } catch (ClosedChannelException e) {
+            // expected
+        }
+        try {
+            readWriteFileChannel.read(readBuffers, 0, 1);
+            fail("should throw ClosedChannelException");
+        } catch (ClosedChannelException e) {
+            // expected
+        }
     }
 
     /**