harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jimmy, Jing Lv (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2276) [classlib][net]DatagramPacket truncate packet length different than RI
Date Thu, 23 Nov 2006 06:34:02 GMT
[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

    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.
public class DatagramSocketTest extends TestCase {
   private final String ADDRESS = "";
   private final int PORT = 6155;
   private MulticastSocket socket = null;
   private byte[] recvData = null;
   private DatagramPacket recvDatagram = null;

   protected void setUp() throws Exception {
       // open a multicast socket
       socket = new MulticastSocket(PORT);
       recvData = new byte[100];
       recvDatagram = new DatagramPacket(recvData, recvData.length);

   protected void tearDown() throws Exception {
       if (socket != null) socket.close();

   private void sendMessage(String message) throws IOException {
       // send the datagram
       byte[] sendData = message.getBytes();
       DatagramPacket sendDatagram = new DatagramPacket(sendData, 0,
               new InetSocketAddress(InetAddress.getByName(ADDRESS), PORT));

   private String receiveMessage() throws IOException {
       // receive the datagram
       socket.setSoTimeout(5000);           // prevent eternal block
in socket.receive()
       String recvMessage = new String(recvData, 0, recvDatagram.getLength());
       return recvMessage;

   public void testReceive() {
       String message = "Hello, world!";
       String longerMessage = message + " again.";

       try {
           assertEquals(message, receiveMessage());

           assertEquals(longerMessage, receiveMessage());
       } catch (IOException e) {
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


View raw message