You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Andrew Zhang (JIRA)" <ji...@apache.org> on 2006/06/29 04:13:30 UTC

[jira] Commented: (HARMONY-701) [classlib][nio] java.nio.channels.DatagramChannel.send(ByteBuffer, SocketAddress) sends data incorrectly if the position of ByteBuffer is not zero.

    [ http://issues.apache.org/jira/browse/HARMONY-701?page=comments#action_12418367 ] 

Andrew Zhang commented on HARMONY-701:
--------------------------------------

Another bug of java.nio.channels.DatagramChannel.send(ByteBuffer, SocketAddress) :

This method doesn't set the right position of ByteBuffer sometimes.

Following test reproduces the bug. I'll fix these two bugs with one patch. 

Thanks!

Test case:

    public void test_send_LBuffer_LSocketAddress_PositonNotZero()
            throws Exception {
        int CAPACITY_NORMAL = 256;
        int postion = 16;
        DatagramChannel dc = DatagramChannel.open();
        SocketAddress addr = new InetSocketAddress("127.0.0.1", 50000);
        byte[] sourceArray = new byte[CAPACITY_NORMAL];
        // send ByteBuffer whose position is not zero
        ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
        sourceBuf.position(postion);
        int ret = dc.send(sourceBuf, addr);
        //assertEquals(CAPACITY_NORMAL - postion, ret);
        assertEquals(CAPACITY_NORMAL, sourceBuf.position());
    }

Test result:
RI 5.0 passes the test while Harmony fails. 

Best regards,
Andrew

> [classlib][nio] java.nio.channels.DatagramChannel.send(ByteBuffer, SocketAddress) sends data incorrectly if the position of ByteBuffer is not zero.
> ---------------------------------------------------------------------------------------------------------------------------------------------------
>
>          Key: HARMONY-701
>          URL: http://issues.apache.org/jira/browse/HARMONY-701
>      Project: Harmony
>         Type: Bug

>   Components: Classlib
>     Reporter: Andrew Zhang

>
> java.nio.channels.DatagramChannel.send(ByteBuffer, SocketAddress) sends data incorrectly if the position of ByteBuffer is not zero.
> Following test case reproduces the bug. 
> I'll upload a patch soon. Thanks! 
> Test case:
>     public void test_send_LBuffer_LSocketAddress_PositionNotZero()  throws Exception {
>         int CAPACITY_NORMAL = 256;
>         int postion = 16;
>         DatagramChannel dc = DatagramChannel.open();
>         SocketAddress addr = new InetSocketAddress("127.0.0.1", 50000);
>         byte[] sourceArray = new byte[CAPACITY_NORMAL];
>         // send ByteBuffer whose position is not zero
>         ByteBuffer sourceBuf = ByteBuffer.wrap(sourceArray);
>         sourceBuf.position(postion);
>         assertEquals(CAPACITY_NORMAL - postion, dc.send(sourceBuf, addr));
>     }
> Test result:
> RI 5.0 passes the test while Harmony fails. 
> Best regards,
> Andrew

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira