You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Endre Stølsvik (JIRA)" <ji...@apache.org> on 2015/03/03 15:28:04 UTC

[jira] [Created] (AMQ-5632) MapMessage.getBytes crashes with NPE if no value present

Endre Stølsvik created AMQ-5632:
-----------------------------------

             Summary: MapMessage.getBytes crashes with NPE if no value present
                 Key: AMQ-5632
                 URL: https://issues.apache.org/jira/browse/AMQ-5632
             Project: ActiveMQ
          Issue Type: Bug
            Reporter: Endre Stølsvik


Compare to AMQ-5628 and AMQ-5629

Read up on http://docs.oracle.com/javaee/1.4/api/javax/jms/MapMessage.html

Notice the wording "if there is no item by this name, a null value is returned."

{code}
    /**
     * Returns the byte array value with the specified name.
     *
     * @param name the name of the byte array
     * @return a copy of the byte array value with the specified name; if there
     *         is no item by this name, a null value is returned.
     * @throws JMSException if the JMS provider fails to read the message due to
     *                 some internal error.
     * @throws MessageFormatException if this type conversion is invalid.
     */
    @Override
    public byte[] getBytes(String name) throws JMSException {
        initializeReading();
        Object value = map.get(name);
        if (value instanceof byte[]) {
            return (byte[])value;
        } else {
            throw new MessageFormatException(" cannot read a byte[] from " + value.getClass().getName());
        }
    }
{code}

Notice how the "else"-block will kick in on null value, whereby we get the "value.getClass()" executed, resulting in NPE.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)