Lorenz Quack created QPID-7897:
----------------------------------

             Summary: [Java 0-8...0-9-1 Client] 
Message#getJMSCorrelationIDAsBytes() erroneously first converts to string 
before retreiving bytes 
                 Key: QPID-7897
                 URL: https://issues.apache.org/jira/browse/QPID-7897
             Project: Qpid
          Issue Type: Bug
          Components: Java Client
            Reporter: Lorenz Quack


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:
{code:title=AMQMessageDelegate_0_8.java}public byte[] 
getJMSCorrelationIDAsBytes() throws JMSException
{
    return getContentHeaderProperties().getCorrelationIdAsString().getBytes();
}{code}
{code:title=BasicContentHeaderProperties}public String 
getCorrelationIdAsString()
{
    return (_correlationId == null) ? null : _correlationId.toString();
}{code}
{code:title=AMQShortString}public String toString()
{
    if (_asString == null)
    {
        _asString = new String(_data, _offset, _length, StandardCharsets.UTF_8);
    }
    return _asString;
}{code}

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.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to