You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Jimmy, Jing Lv (JIRA)" <ji...@apache.org> on 2006/11/23 07:34:02 UTC

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

[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


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

        

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

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov resolved HARMONY-2276.
--------------------------------------

    Resolution: Fixed

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Alexei Zakharov
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Leo Li (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-2276?page=all ]

Leo Li updated HARMONY-2276:
----------------------------

    Attachment: patch-2276.diff

Will somebody try this?

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

        

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

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Mikhail Markov updated HARMONY-2276:
------------------------------------

    Attachment: H-2276_updated_1.patch

Hi, Tim!
Here is the patch re-based to the current Harmony sources. I've checked the regression test once again both on WinXP and Linux (both standalone and as a part of luni junit-tests) - it passed.

Could you please check again if this patch works for you?

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Assigned To: Tim Ellison
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison updated HARMONY-2276:
---------------------------------

    Attachment: harmony-2276-updated.patch

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Assigned To: Tim Ellison
>         Attachments: H-2276.patch, harmony-2276-updated.patch, 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: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500969 ] 

Alexei Zakharov commented on HARMONY-2276:
------------------------------------------

Mikhail, I've reworked your patch for DatagramPacket a little bit, added a couple of new test cases to DatagramSocketTest, improved readability of DatagramSocket#receive() and fixed MulticastSocketTest since it started to fail after applying your/my patch. All these changes were committed at the revision 543786. Please take a look. Thanks!

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Alexei Zakharov
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12505321 ] 

Mikhail Markov commented on HARMONY-2276:
-----------------------------------------

Alexei - i've reviewed your patch and it looks good to me. Thanks for improvements!

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Alexei Zakharov
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov closed HARMONY-2276.
------------------------------------


Issue closed.

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Alexei Zakharov
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ 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

        

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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499762 ] 

Tim Ellison commented on HARMONY-2276:
--------------------------------------

Sorry guys, I still cannot get this patch to pass the tests on my Win XP/x86 machine.

I still get a :


> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Tim Ellison
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12499763 ] 

Tim Ellison commented on HARMONY-2276:
--------------------------------------

(Continued from last comment)

expected:<... again.> but was:<...>

junit.framework.ComparisonFailure: expected:<... again.> but was:<...> at tests.api.java.net.DatagramSocketTest.test_receiveLjava_net_DatagramPacket(DatagramSocketTest.java:96) at java.lang.reflect.AccessibleObject.invokeV(AccessibleObject.java:25)

Not sure how to fix that.  Maybe it is a firewall issue or something.  I'm going to unassign this issue from me since I cannot in good faith commit it and not sure I can advance it further.


> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Tim Ellison
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12463642 ] 

Mikhail Markov commented on HARMONY-2276:
-----------------------------------------

Hmm, Tim - i've checked your updated patch and it looks fine. Also i've cleanly applied it locally, fully rebuilt classlib (with clean) and re-run all luni tests on WinXP IA32 - all passed. What platform did you test on?

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Assigned To: Tim Ellison
>         Attachments: H-2276.patch, harmony-2276-updated.patch, 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: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Posted by "Mikhail Markov (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-2276?page=all ]

Mikhail Markov updated HARMONY-2276:
------------------------------------

    Attachment: H-2276.patch

Hi, Tim, Leo!

1) I've checked patch from Leo - it really works :-).
When i applied it and recompile 'luni' module without full cleanup - i've also got the same message as you, but after full classlib cleanup and rebuilding all the test passed.

2) I've slightly modified the patch from Leo to avoid getting java field from native.
Could you please take a look if it makes sense? Thanks!

> [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: H-2276.patch, 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

        

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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-2276?page=all ]

Tim Ellison reassigned HARMONY-2276:
------------------------------------

    Assignee: Tim Ellison

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

        

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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison reassigned HARMONY-2276:
------------------------------------

    Assignee:     (was: Tim Ellison)

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Leo Li (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-2276?page=comments#action_12458353 ] 
            
Leo Li commented on HARMONY-2276:
---------------------------------

Hi, Tim:
       It passes on my machine. Maybe you can rebuild natvies on Harmony since there are modified native codes included.
       As to the getCapacityFromDatagramPacket, it is really a problem. But since the capacity cannot be represented or deduced by other public fields specified by spec,  and the implementation of DatagramSocket is in another package, it will be quite difficult to transfer it to the callee.  I will try to think a way out.
      Any suggestion?

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

        

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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12463617 ] 

Tim Ellison commented on HARMONY-2276:
--------------------------------------

I updated the patch as harmony-2276-updated.patch but when applying it I get a failure in the regression test case.  The send of the longer data is received as the short length ('Hello, World!' without the ' again').  Please can you take a look and see if I accurately updated your patch?


> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>         Assigned To: Tim Ellison
>         Attachments: H-2276.patch, harmony-2276-updated.patch, 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: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

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

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12500970 ] 

Alexei Zakharov commented on HARMONY-2276:
------------------------------------------

Note: I've tested the final patch on Win and Linux IA32 and didn't see any failures. Hope this new patch will work for Tim too.

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Alexei Zakharov
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.


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

Posted by "Alexei Zakharov (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-2276?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Alexei Zakharov reassigned HARMONY-2276:
----------------------------------------

    Assignee: Alexei Zakharov

> [classlib][net]DatagramPacket truncate packet length different than RI
> ----------------------------------------------------------------------
>
>                 Key: HARMONY-2276
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2276
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Jimmy, Jing Lv
>            Assignee: Alexei Zakharov
>         Attachments: H-2276.patch, H-2276_updated_1.patch, harmony-2276-updated.patch, 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.
-
You can reply to this email to add a comment to the issue online.