You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Tim Ellison (JIRA)" <ji...@apache.org> on 2006/12/13 14:37:22 UTC

[jira] Commented: (HARMONY-2276) [classlib][net]DatagramPacket truncate packet length different than RI

    [ http://issues.apache.org/jira/browse/HARMONY-2276?page=comments#action_12458113 ] 
            
Tim Ellison commented on HARMONY-2276:
--------------------------------------

Leo.

I'm a bit concerned that the patch now requires that each Datagram read will require a call to find the DatagramPacket class, and the capacity field (i.e. the getCapacityFromDatagramPacket function).  Since this is likely to be performance sensitive the field ID should be cached in a VMLS variable.

When I applied the patch and ran the tests I got a failure as follows:
junit.framework.ComparisonFailure: expected:<... again.> but was:<...> at tests.api.java.net.DatagramSocketTest.test_receiveLjava_net_DatagramPacket(DatagramSocketTest.java:92)

I assume the tests are working for you?


> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: http://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Assigned To: Tim Ellison
>         Attachments: patch-2276.diff
>
>
> Hi,
>     Though spec reads un-clear, RI sets packet length of DatagramPacket to its orginal length in receiving, but Harmony remember its perious received length. As a result, if the perious received bytes are shorter than the next input, it will cause a truncate different than RI.
> testcase:
> public class DatagramSocketTest extends TestCase {
>    private final String ADDRESS = "239.255.2.3";
>    private final int PORT = 6155;
>    private MulticastSocket socket = null;
>    private byte[] recvData = null;
>    private DatagramPacket recvDatagram = null;
>    @Override
>    protected void setUp() throws Exception {
>        super.setUp();
>        // open a multicast socket
>        socket = new MulticastSocket(PORT);
>        socket.joinGroup(InetAddress.getByName(ADDRESS));
>        recvData = new byte[100];
>        recvDatagram = new DatagramPacket(recvData, recvData.length);
>    }
>    @Override
>    protected void tearDown() throws Exception {
>        if (socket != null) socket.close();
>        super.tearDown();
>    }
>    private void sendMessage(String message) throws IOException {
>        // send the datagram
>        byte[] sendData = message.getBytes();
>        DatagramPacket sendDatagram = new DatagramPacket(sendData, 0,
> sendData.length,
>                new InetSocketAddress(InetAddress.getByName(ADDRESS), PORT));
>        socket.send(sendDatagram);
>    }
>    private String receiveMessage() throws IOException {
>        // receive the datagram
>        socket.setSoTimeout(5000);           // prevent eternal block
> in socket.receive()
>        socket.receive(recvDatagram);
>        String recvMessage = new String(recvData, 0, recvDatagram.getLength());
>        return recvMessage;
>    }
>    public void testReceive() {
>        String message = "Hello, world!";
>        String longerMessage = message + " again.";
>        try {
>            sendMessage(message);
>            assertEquals(message, receiveMessage());
>            sendMessage(longerMessage);
>            assertEquals(longerMessage, receiveMessage());
>        } catch (IOException e) {
>            //ignore
>        }
>    }
> }
> Result: RI pass, but Harmony fails.

-- 
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