Return-Path: X-Original-To: apmail-activemq-commits-archive@www.apache.org Delivered-To: apmail-activemq-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1527210E19 for ; Tue, 3 Mar 2015 21:28:37 +0000 (UTC) Received: (qmail 87634 invoked by uid 500); 3 Mar 2015 21:28:34 -0000 Delivered-To: apmail-activemq-commits-archive@activemq.apache.org Received: (qmail 87590 invoked by uid 500); 3 Mar 2015 21:28:33 -0000 Mailing-List: contact commits-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@activemq.apache.org Delivered-To: mailing list commits@activemq.apache.org Received: (qmail 87581 invoked by uid 99); 3 Mar 2015 21:28:33 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 03 Mar 2015 21:28:33 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 78576E03B9; Tue, 3 Mar 2015 21:28:33 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tabish@apache.org To: commits@activemq.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: activemq git commit: https://issues.apache.org/jira/browse/AMQ-5628 Date: Tue, 3 Mar 2015 21:28:33 +0000 (UTC) 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 Authored: Tue Mar 3 16:28:28 2015 -0500 Committer: Timothy Bish 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";