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-5628) MapMessage.getDouble uses Float when converting from String/UTF8
Date Tue, 03 Mar 2015 12:28:04 GMT
Endre Stølsvik created AMQ-5628:
-----------------------------------

             Summary: MapMessage.getDouble uses Float when converting from String/UTF8
                 Key: AMQ-5628
                 URL: https://issues.apache.org/jira/browse/AMQ-5628
             Project: ActiveMQ
          Issue Type: Bug
            Reporter: Endre Stølsvik


ActiveMqMapMessage, line ~437:

{code}
    public double getDouble(String name) throws JMSException {
        initializeReading();
        Object value = map.get(name);
        if (value == null) {
            return 0;
        }
        if (value instanceof Double) {
            return ((Double)value).doubleValue();
        }
        if (value instanceof Float) {
            return ((Float)value).floatValue();
        }
        if (value instanceof UTF8Buffer) {
            return Float.valueOf(value.toString()).floatValue();
        }
        if (value instanceof String) {
            return Float.valueOf(value.toString()).floatValue();
        } else {
            throw new MessageFormatException(" cannot read a double from " + value.getClass().getName());
        }
    }
{code}

Notice the ifs on String or UTF8Buffer and the use of Float.valueOf.

I noticed this when Strings representing anything higher than Float.MAX_VALUE ended up as
Infinity, and anything below Float.MIN_VALUE ended up as 0.



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

Mime
View raw message