activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Barry Kaplan (JIRA)" <>
Subject [jira] Commented: (AMQ-1282) Bad conversion of nonexistent data in MapMessage
Date Tue, 02 Sep 2008 16:35:52 GMT


Barry Kaplan commented on AMQ-1282:

#getBytes also appears to be incorrect in two ways. 

First, from  [MapMessage.html|]
this method should return null if the entry does not exist. From the code, it appears as if
MessageFormatException is thrown instead.

Second, if an attempt is made to MessageFormatException for a null value, an NPE will be generated
due to the "value.getClass().getName()".

public byte[] getBytes(String name) throws JMSException {
        Object value = map.get(name);
        if (value instanceof byte[]) {
            return (byte[])value;
        } else {
            throw new MessageFormatException(" cannot read a byte[] from " + value.getClass().getName());

> Bad conversion of nonexistent data in MapMessage
> ------------------------------------------------
>                 Key: AMQ-1282
>                 URL:
>             Project: ActiveMQ
>          Issue Type: Bug
>          Components: JMS client
>    Affects Versions: 4.1.1
>            Reporter: Elliotte Rusty Harold
>             Fix For: 5.2.0
>         Attachments:
> Consider simple reception code like this:
>         MapMessage message = (MapMessage) consumer.receive(1000);
>         int x = message.getInt("foo"));
> I notice that x is now set to zero even though there was no "foo" value in the map. I
would have expected an exception.
> According to Gaurav Hariani <> 	
> also from the spec api:
>     Attempting to read a null value as a primitive type must be treated as calling the
primitive's corresponding valueOf(String) conversion method with a null value. Since char
does not support a String conversion, attempting to read a null value as a char must throw
a NullPointerException.
> .. so you are right that it is a bug ... since Integer.valueOf(null) throws an Exception

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message