harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r425318 - 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
Date Tue, 25 Jul 2006 07:46:11 GMT
Author: pyang
Date: Tue Jul 25 00:46:11 2006
New Revision: 425318

URL: http://svn.apache.org/viewvc?rev=425318&view=rev
Log:
Fix for HARMONY-972 ([classlib][nio]java.nio.channels.FileChannel.read(ByteBuffer,long) fails
to read with a positioned bytebuffer correctly)

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=425318&r1=425317&r2=425318&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
Tue Jul 25 00:46:11 2006
@@ -275,7 +275,8 @@
                      * if (bytesRead <= EOF) delt by read completed = false;
                      */
                     bytesRead = (int) fileSystem.read(handle, buffer.array(),
-                            buffer.arrayOffset(), buffer.remaining());
+                            buffer.arrayOffset() + buffer.position(), buffer
+                                    .remaining());
                     completed = true;
                 } finally {
                     end(completed && bytesRead >= 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=425318&r1=425317&r2=425318&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
Tue Jul 25 00:46:11 2006
@@ -1339,11 +1339,16 @@
         writeDataToFile(fileOfReadOnlyFileChannel);
         ByteBuffer readBuffer = ByteBuffer.allocate(CAPACITY);
 
+        final int BUFFER_POSITION = 1;
+        readBuffer.position(BUFFER_POSITION);
+
         final int POSITION = 2;
         int result = readOnlyFileChannel.read(readBuffer, POSITION);
         assertEquals(CONTENT_AS_BYTES_LENGTH - POSITION, result);
+        assertEquals(BUFFER_POSITION + result, readBuffer.position());
 
         readBuffer.flip();
+        readBuffer.position(BUFFER_POSITION);
         for (int i = POSITION; i < CONTENT_AS_BYTES_LENGTH; i++) {
             assertEquals(CONTENT_AS_BYTES[i], readBuffer.get());
         }



Mime
View raw message