Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-5628

MapMessage.getDouble uses Float when converting from String/UTF8

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 5.12.0
    • None
    • None

    Description

      ActiveMqMapMessage, line ~437:

          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());
              }
          }
      

      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.

      Attachments

        Issue Links

          Activity

            People

              tabish Timothy A. Bish
              stolsvik Endre Stølsvik
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: