harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r963690 - in /harmony/enhanced/java/trunk/classlib/modules/nio/src: main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
Date Tue, 13 Jul 2010 12:36:05 GMT
Author: tellison
Date: Tue Jul 13 12:36:04 2010
New Revision: 963690

URL: http://svn.apache.org/viewvc?rev=963690&view=rev
Log:
Apply slightly modified patch for HARMONY-6580 ([classlib][nio] SocketChannel.write eat more
bytes than expected)

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

Modified: harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java?rev=963690&r1=963689&r2=963690&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/nio/src/main/java/common/org/apache/harmony/nio/internal/SocketChannelImpl.java
Tue Jul 13 12:36:04 2010
@@ -524,8 +524,8 @@ class SocketChannelImpl extends SocketCh
         for (int i = offset; i < length + offset; i++) {
             if (bytesRemaining > sources[i].remaining()) {
                 int pos = sources[i].limit();
-                sources[i].position(pos);
                 bytesRemaining -= sources[i].remaining();
+                sources[i].position(pos);
             } else {
                 int pos = sources[i].position() + (int) bytesRemaining;
                 sources[i].position(pos);

Modified: harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java?rev=963690&r1=963689&r2=963690&view=diff
==============================================================================
--- harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
(original)
+++ harmony/enhanced/java/trunk/classlib/modules/nio/src/test/java/common/org/apache/harmony/nio/tests/java/nio/channels/SocketChannelTest.java
Tue Jul 13 12:36:04 2010
@@ -2772,6 +2772,40 @@ public class SocketChannelTest extends T
     /**
      * @tests java.nio.channels.SocketChannel#write(ByteBuffer[])
      */
+    public void test_writev2() throws Exception {
+        ServerSocketChannel ssc = ServerSocketChannel.open();
+        ssc.configureBlocking(false);
+        ssc.socket().bind(null);
+        SocketChannel sc = SocketChannel.open();
+        sc.configureBlocking(false);
+        boolean connected = sc.connect(ssc.socket().getLocalSocketAddress());
+        SocketChannel sock = ssc.accept();
+        if (!connected) {
+            sc.finishConnect();
+        }
+
+        ByteBuffer buf1 = ByteBuffer.allocate(10);
+        sc.socket().setSendBufferSize(512);
+        int bufSize = sc.socket().getSendBufferSize();
+        ByteBuffer buf2 = ByteBuffer.allocate(bufSize * 10);
+
+        ByteBuffer[] sent = new ByteBuffer[2];
+        sent[0] = buf1;
+        sent[1] = buf2;
+
+        long whole = buf1.remaining() + buf2.remaining();
+
+        long write = sc.write(sent);
+        ssc.close();
+        sc.close();
+        sock.close();
+
+        assertTrue(whole == (write + buf1.remaining() + buf2.remaining()));
+    }
+
+    /**
+     * @tests java.nio.channels.SocketChannel#write(ByteBuffer[])
+     */
     public void test_write$LByteBuffer2() throws IOException {
         // Set-up
         ServerSocketChannel server = ServerSocketChannel.open();



Mime
View raw message