camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1294978 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
Date Wed, 29 Feb 2012 05:30:35 GMT
Author: davsclaus
Date: Wed Feb 29 05:30:35 2012
New Revision: 1294978

URL: http://svn.apache.org/viewvc?rev=1294978&view=rev
Log:
CAMEL-4959: Type convertion with NaN numbers requires a bit special handling.

Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 29 05:30:35 2012
@@ -1 +1 @@
-/camel/trunk:1243046,1243057,1243234,1244518,1244644,1244859,1244861,1244864,1244870,1244872,1245021,1291555,1291727,1291848,1291864,1292114,1292384,1292725,1292760,1292767,1293079,1293268,1293288,1293330,1293590,1293828,1293852,1293855,1294130,1294482,1294502,1294533,1294588,1294639,1294709,1294909
+/camel/trunk:1243046,1243057,1243234,1244518,1244644,1244859,1244861,1244864,1244870,1244872,1245021,1291555,1291727,1291848,1291864,1292114,1292384,1292725,1292760,1292767,1293079,1293268,1293288,1293330,1293590,1293828,1293852,1293855,1294130,1294482,1294502,1294533,1294588,1294639,1294709,1294909,1294976

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java?rev=1294978&r1=1294977&r2=1294978&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/util/ObjectHelper.java
Wed Feb 29 05:30:35 2012
@@ -1384,9 +1384,10 @@ public final class ObjectHelper {
      * @return <tt>true</tt> if its a {@link Float#NaN} or {@link Double#NaN}.
      */
     public static boolean isNaN(Object value) {
-        if (value == null) {
+        if (value == null || !(value instanceof Number)) {
             return false;
         }
+        // value must be a number
         return value.equals(Float.NaN) || value.equals(Double.NaN);
     }
 

Modified: camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java?rev=1294978&r1=1294977&r2=1294978&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
(original)
+++ camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/util/ObjectHelperTest.java
Wed Feb 29 05:30:35 2012
@@ -346,5 +346,19 @@ public class ObjectHelperTest extends Te
         String code3 = ObjectHelper.getIdentityHashCode(dummyB);
         assertNotSame(code, code3);
     }
+    
+    public void testIsNaN() throws Exception {
+        assertTrue(ObjectHelper.isNaN(Float.NaN));
+        assertTrue(ObjectHelper.isNaN(Double.NaN));
+
+        assertFalse(ObjectHelper.isNaN(null));
+        assertFalse(ObjectHelper.isNaN(""));
+        assertFalse(ObjectHelper.isNaN("1.0"));
+        assertFalse(ObjectHelper.isNaN(1));
+        assertFalse(ObjectHelper.isNaN(1.5f));
+        assertFalse(ObjectHelper.isNaN(1.5d));
+        assertFalse(ObjectHelper.isNaN(false));
+        assertFalse(ObjectHelper.isNaN(true));
+    }
 
 }



Mime
View raw message