Uploaded image for project: 'Qpid'
  1. Qpid
  2. QPID-7897

[Java 0-8...0-9-1 Client] Message#getJMSCorrelationIDAsBytes() erroneously first converts to string before retreiving bytes

    XMLWordPrintableJSON

    Details

      Description

      If the correlationId of a message does not contain valid UTF_8 (e.g., set via javax.jms.Message#setJMSCorrelationIDAsBytes) then javax.jms.Message#getJMSCorrelationIDAsBytes does not return the correct value.

      Some relevant code snippets:AMQMessageDelegate_0_8#getJMSCorrelationIDAsBytes is implemented as follows:

      AMQMessageDelegate_0_8.java
      public byte[] getJMSCorrelationIDAsBytes() throws JMSException
      {
          return getContentHeaderProperties().getCorrelationIdAsString().getBytes();
      }
      BasicContentHeaderProperties
      public String getCorrelationIdAsString()
      {
          return (_correlationId == null) ? null : _correlationId.toString();
      }
      AMQShortString
      public String toString()
      {
          if (_asString == null)
          {
              _asString = new String(_data, _offset, _length, StandardCharsets.UTF_8);
          }
          return _asString;
      }

      If _data does not contain valid UTF_8 the result of this call chain is incorrect.
      I do not see a reason why AMQMessageDelegate_0_8#getJMSCorrelationIDAsBytes should not return getContentHeaderProperties().getCorrelationId().getBytes() instead.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                lorenz.quack Lorenz Quack
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: