activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Endre Stølsvik (JIRA) <j...@apache.org>
Subject [jira] [Created] (AMQ-5632) MapMessage.getBytes crashes with NPE if no value present
Date Tue, 03 Mar 2015 14:28:04 GMT
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)

Mime
View raw message