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/03 13:28:04 UTC
[jira] [Created] (AMQ-5628) MapMessage.getDouble uses Float when
converting from String/UTF8
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)