activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-5628
Date Tue, 03 Mar 2015 21:28:33 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 6e038d5ff -> 4b346360b


https://issues.apache.org/jira/browse/AMQ-5628

Fix getDouble to use Double.valueOf instead of Float.valueOf for
conversions.

Project: http://git-wip-us.apache.org/repos/asf/activemq/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq/commit/4b346360
Tree: http://git-wip-us.apache.org/repos/asf/activemq/tree/4b346360
Diff: http://git-wip-us.apache.org/repos/asf/activemq/diff/4b346360

Branch: refs/heads/master
Commit: 4b346360be63d5b60d94eb47f86d24e1d20dd2fe
Parents: 6e038d5
Author: Timothy Bish <tabish121@gmail.com>
Authored: Tue Mar 3 16:28:28 2015 -0500
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Tue Mar 3 16:28:28 2015 -0500

----------------------------------------------------------------------
 .../activemq/command/ActiveMQMapMessage.java     | 19 ++++++++-----------
 .../activemq/command/ActiveMQMapMessageTest.java | 16 ++++++++++++++++
 2 files changed, 24 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/4b346360/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
index 11bee21..7fac237 100755
--- a/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
+++ b/activemq-client/src/main/java/org/apache/activemq/command/ActiveMQMapMessage.java
@@ -437,22 +437,19 @@ public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage
{
     public double getDouble(String name) throws JMSException {
         initializeReading();
         Object value = map.get(name);
+
         if (value == null) {
             return 0;
-        }
-        if (value instanceof Double) {
+        } else if (value instanceof Double) {
             return ((Double)value).doubleValue();
-        }
-        if (value instanceof Float) {
+        } else 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 if (value instanceof UTF8Buffer) {
+            return Double.valueOf(value.toString()).doubleValue();
+        } else if (value instanceof String) {
+            return Double.valueOf(value.toString()).doubleValue();
         } else {
-            throw new MessageFormatException(" cannot read a double from " + value.getClass().getName());
+            throw new MessageFormatException("Cannot read a double from " + value.getClass().getName());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/4b346360/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java
index a7c0dec..52f4232 100755
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/command/ActiveMQMapMessageTest.java
@@ -157,6 +157,22 @@ public class ActiveMQMapMessageTest {
     }
 
     @Test(timeout = 10000)
+    public void testGetDoubleWithMaxValue() throws JMSException {
+        ActiveMQMapMessage msg = new ActiveMQMapMessage();
+        msg.setDouble(this.name, Double.MAX_VALUE);
+        msg = (ActiveMQMapMessage) msg.copy();
+        assertEquals(Double.MAX_VALUE, msg.getDouble(this.name), 1.0);
+    }
+
+    @Test(timeout = 10000)
+    public void testGetDoubleWithMaxValueAsString() throws JMSException {
+        ActiveMQMapMessage msg = new ActiveMQMapMessage();
+        msg.setString(this.name, String.valueOf(Double.MAX_VALUE));
+        msg = (ActiveMQMapMessage) msg.copy();
+        assertEquals(Double.MAX_VALUE, msg.getDouble(this.name), 1.0);
+    }
+
+    @Test(timeout = 10000)
     public void testGetString() throws JMSException {
         ActiveMQMapMessage msg = new ActiveMQMapMessage();
         String str = "test";


Mime
View raw message