commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r1054202 - in /commons/proper/lang/trunk/src: main/java/org/apache/commons/lang3/math/NumberUtils.java test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
Date Sat, 01 Jan 2011 06:57:00 GMT
Author: bayard
Date: Sat Jan  1 06:56:59 2011
New Revision: 1054202

URL: http://svn.apache.org/viewvc?rev=1054202&view=rev
Log:
Fixing NumberUtils.isNumber so that 1.1L is not considered a number. LANG-664

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
    commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java?rev=1054202&r1=1054201&r2=1054202&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
(original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/math/NumberUtils.java
Sat Jan  1 06:56:59 2011
@@ -1409,8 +1409,8 @@ public class NumberUtils {
             }
             if (chars[i] == 'l'
                 || chars[i] == 'L') {
-                // not allowing L with an exponent
-                return foundDigit && !hasExp;
+                // not allowing L with an exponent or decimal point
+                return foundDigit && !hasExp && !hasDecPoint;
             }
             // last character is illegal
             return false;

Modified: commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java?rev=1054202&r1=1054201&r2=1054202&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
(original)
+++ commons/proper/lang/trunk/src/test/java/org/apache/commons/lang3/math/NumberUtilsTest.java
Sat Jan  1 06:56:59 2011
@@ -1139,6 +1139,10 @@ public class NumberUtilsTest extends Tes
         // LANG-521
         val = "2.";
         assertTrue("isNumber(String) LANG-521 failed", NumberUtils.isNumber(val));
+
+        // LANG-664
+        val = "1.1L";
+        assertFalse("isNumber(String) LANG-664 failed", NumberUtils.isNumber(val));
     }
 
     private boolean checkCreateNumber(String val) {



Mime
View raw message