[ 
https://issues.apache.org/jira/browse/AMQ-5633?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Timothy Bish closed AMQ-5633.
-----------------------------
    Resolution: Not a Problem

This is working as the spec defines it to

"Getting a property value for a name which has not been set returns a null 
value. Only the getStringProperty and getObjectProperty methods can return a 
null value. 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. "

Calling Boolean.valueOf(null) returns false.

> MapMessage.getBooleanProperty should probably throw if value not present
> ------------------------------------------------------------------------
>
>                 Key: AMQ-5633
>                 URL: https://issues.apache.org/jira/browse/AMQ-5633
>             Project: ActiveMQ
>          Issue Type: Bug
>            Reporter: Endre Stølsvik
>
> Compared to the other property getters (except for String and Object, which 
> are clearly documented in spec as should return null), the getBoolanProperty 
> just returns false if the value is not present.
> MapMessage, line ~583:
> {code}
>     public boolean getBooleanProperty(String name) throws JMSException {
>         Object value = getObjectProperty(name);
>         if (value == null) {
>             return false;
>         }
>         Boolean rc = (Boolean) TypeConversionSupport.convert(value, 
> Boolean.class);
>         if (rc == null) {
>             throw new MessageFormatException("Property " + name + " was a " + 
> value.getClass().getName() + " and cannot be read as a boolean");
>         }
>         return rc.booleanValue();
>     }
> {code}
> Compared to e.g. getByteProperty right below:
> {code}
>     public byte getByteProperty(String name) throws JMSException {
>         Object value = getObjectProperty(name);
>         if (value == null) {
>             throw new NumberFormatException("property " + name + " was null");
>         }
>         Byte rc = (Byte) TypeConversionSupport.convert(value, Byte.class);
>         if (rc == null) {
>             throw new MessageFormatException("Property " + name + " was a " + 
> value.getClass().getName() + " and cannot be read as a byte");
>         }
>         return rc.byteValue();
>     }
> {code}
> or getFloatProperty some methods below:
> {code}
>     public float getFloatProperty(String name) throws JMSException {
>         Object value = getObjectProperty(name);
>         if (value == null) {
>             throw new NullPointerException("property " + name + " was null");
>         }
>         Float rc = (Float) TypeConversionSupport.convert(value, Float.class);
>         if (rc == null) {
>             throw new MessageFormatException("Property " + name + " was a " + 
> value.getClass().getName() + " and cannot be read as a float");
>         }
>         return rc.floatValue();
>     }
> {code}



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

Reply via email to