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-5633) MapMessage.getBooleanProperty should probably throw if value not present
Date Wed, 04 Mar 2015 00:12:04 GMT
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)

Mime
View raw message