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/04 01:12:04 UTC

[jira] [Created] (AMQ-5633) MapMessage.getBooleanProperty should probably throw if value not present

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

             Summary: 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)