activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Brian D. Johnson (JIRA)" <>
Subject [jira] [Created] (AMQ-5381) ActiveMQBytesMessage mishandles restoration of old message contents
Date Thu, 02 Oct 2014 14:16:33 GMT
Brian D. Johnson created AMQ-5381:

             Summary: ActiveMQBytesMessage mishandles restoration of old message contents
                 Key: AMQ-5381
             Project: ActiveMQ
          Issue Type: Bug
          Components: JMS client
    Affects Versions: 5.10.0, 5.9.1
            Reporter: Brian D. Johnson

Changes made in ActiveMQ 5.9.1, AMQ-4887, [[cb5c29d02d02dc7f7fa4f5c1a97bd2a59078bccd|]]
introduced a bug in {{ActiveMQBytesMessage}} which results in a {{
incorrect header check}} being thrown at {{org.apache.activemq.command.ActiveMQBytesMessage.restoreOldContent(}}
when a consumer attempts to reuse a received {{ActiveMQBytesMessage}}.

This bug is triggered under a unique set of circumstances:
# A message is published by a JMS client with compression *_disabled_* on its {{ActiveMQConnection}}
# The message is consumed by a JMS client with compression *_enabled_* on its {{ActiveMQConnection}}
# The JMS consumer makes the received message writable in order to modify and reuse it:
# The JMS consumer modifies the message, triggering a call to {{ActiveMQBytesMessage.initializeWriting()}}

The problem within {{ActiveMQBytesMessage.initializeWriting()}} is that the method determines
whether the message should be compressed _when it is published_ (based on its current connection)
BEFORE it has restored the message's original content.  In the example above, the message's
original {{compressed}} flag is changed from {{false}} to {{true}}, resulting in {{restoreOldContent()}}
trying to decompress message contents which were never compressed.

private void initializeWriting() throws JMSException {
        if (this.dataOut == null) {
            this.bytesOut = new ByteArrayOutputStream();
            OutputStream os = bytesOut;
            this.dataOut = new DataOutputStream(os);

        // should compression be used when publishing this message??
        ActiveMQConnection connection = getConnection();
        if (connection != null && connection.isUseCompression()) {
            compressed = true;

        // restore the message's old content

A simple solution would be to move the {{restoreOldContent()}} method call before the {{connection.isUseCompression()}}
conditional in {{ActiveMQBytesMessage.initializeWriting()}}.

This message was sent by Atlassian JIRA

View raw message