You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@activemq.apache.org by "Timothy Bish (JIRA)" <ji...@apache.org> on 2015/03/03 22:30:05 UTC

[jira] [Resolved] (AMQ-5628) MapMessage.getDouble uses Float when converting from String/UTF8

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

Timothy Bish resolved AMQ-5628.
-------------------------------
       Resolution: Fixed
    Fix Version/s: 5.12.0
         Assignee: Timothy Bish

Fixed on master, conversions now use Double instead of Float.

> 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
>            Assignee: Timothy Bish
>             Fix For: 5.12.0
>
>
> 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)