Qpid
  1. Qpid
  2. QPID-3715

On receiving an empty ObjectMessage java client hangs forever

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.15
    • Fix Version/s: 0.15
    • Component/s: Java Client
    • Labels:
      None

      Description

      If ObjectMessage message is created and sent without a body than on receiving such a message the consumer hangs regardless whether timeout specified or not.

      The following snippet demonstrates the problem

      Sending and receiving an empty object message
      Message message = session.createObjectMessage();
      producer.send(message);
      ObjectMessage receivedMessage = (ObjectMessage) consumer.receive(1000);// <--- hanging here
      

        Activity

        Hide
        Alex Rudyy added a comment -

        Patch with a fix attached.

        Show
        Alex Rudyy added a comment - Patch with a fix attached.
        Hide
        Alex Rudyy added a comment -

        Keith,

        Do you mind to review and commit the patch attached?

        Show
        Alex Rudyy added a comment - Keith, Do you mind to review and commit the patch attached?
        Hide
        Keith Wall added a comment -

        Hi Alex,

        I can't fault your implementation, but I wonder if there is a reason not to use org.apache.qpid.server.util.ByteBufferInputStream? Admittedly, we'd need to move the class from broker to common (and add a new ByteBufferInputStreamTest). What do you think?

        Show
        Keith Wall added a comment - Hi Alex, I can't fault your implementation, but I wonder if there is a reason not to use org.apache.qpid.server.util.ByteBufferInputStream? Admittedly, we'd need to move the class from broker to common (and add a new ByteBufferInputStreamTest). What do you think?
        Hide
        Alex Rudyy added a comment -

        Hi Keith,

        It seems like ByteBufferInputStream can be used in this case.

        However, IMHO, it requires one modification in its method "int read()"

            @Override
            public int read() throws IOException
            {
                return _buffer.get() & 0xFF;
            }
        

        I am not sure that operation "& 0xFF" is necessary here.

        Do you mind if I change org.apache.qpid.server.util.ByteBufferInputStream and remove "& 0xFF"?

        Show
        Alex Rudyy added a comment - Hi Keith, It seems like ByteBufferInputStream can be used in this case. However, IMHO, it requires one modification in its method "int read()" @Override public int read() throws IOException { return _buffer.get() & 0xFF; } I am not sure that operation "& 0xFF" is necessary here. Do you mind if I change org.apache.qpid.server.util.ByteBufferInputStream and remove "& 0xFF"?
        Hide
        Keith Wall added a comment -

        Isn't it because an implementation of InputStream#read() is required to return the byte as an int in the range 0..255 rather than value -127..128? I think ByteBufferInputStream#read() should be guarding the get() with hasRemaining (in the way you did in your patch) and returning -1 when the ByteBuffer is exhausted.

        Show
        Keith Wall added a comment - Isn't it because an implementation of InputStream#read() is required to return the byte as an int in the range 0..255 rather than value -127..128? I think ByteBufferInputStream#read() should be guarding the get() with hasRemaining (in the way you did in your patch) and returning -1 when the ByteBuffer is exhausted.
        Hide
        Alex Rudyy added a comment -

        Hi Keith,

        Could you please review the attached patch again?

        As agreed I changed JMSObjectMessage to use ByteBufferInputStream, moved ByteBufferInputStream from server module into common and added junit tests for ByteBufferInputStream.

        Show
        Alex Rudyy added a comment - Hi Keith, Could you please review the attached patch again? As agreed I changed JMSObjectMessage to use ByteBufferInputStream, moved ByteBufferInputStream from server module into common and added junit tests for ByteBufferInputStream.
        Hide
        Keith Wall added a comment -

        No further comments, patch applied.

        Show
        Keith Wall added a comment - No further comments, patch applied.

          People

          • Assignee:
            Keith Wall
            Reporter:
            Alex Rudyy
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development