commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r488819 - in /jakarta/commons/proper/lang/trunk/src: java/org/apache/commons/lang/NumberUtils.java java/org/apache/commons/lang/math/NumberUtils.java test/org/apache/commons/lang/math/NumberUtilsTest.java
Date Tue, 19 Dec 2006 21:50:05 GMT
Author: bayard
Date: Tue Dec 19 13:50:04 2006
New Revision: 488819

URL: http://svn.apache.org/viewvc?view=rev&rev=488819
Log:
Fixing LANG-300 (reported by Jeremy Lemaire) - 1L to 9L incorrectly throw exceptions when
passed into NumberUtils.createNumber. Fixed in both the math.NumbersUtils and the deprecated
NumberUtils classes. 

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

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/NumberUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/NumberUtils.java?view=diff&rev=488819&r1=488818&r2=488819
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/NumberUtils.java (original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/NumberUtils.java Tue
Dec 19 13:50:04 2006
@@ -192,8 +192,7 @@
                 case 'L' :
                     if (dec == null
                         && exp == null
-                        && isDigits(numeric.substring(1))
-                        && (numeric.charAt(0) == '-' || Character.isDigit(numeric.charAt(0))))
{
+                        && (numeric.charAt(0) == '-' && isDigits(numeric.substring(1))
|| isDigits(numeric))) {
                         try {
                             return createLong(numeric);
                         } catch (NumberFormatException nfe) {

Modified: jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java?view=diff&rev=488819&r1=488818&r2=488819
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/java/org/apache/commons/lang/math/NumberUtils.java
Tue Dec 19 13:50:04 2006
@@ -451,8 +451,7 @@
                 case 'L' :
                     if (dec == null
                         && exp == null
-                        && isDigits(numeric.substring(1))
-                        && (numeric.charAt(0) == '-' || Character.isDigit(numeric.charAt(0))))
{
+                        && (numeric.charAt(0) == '-' && isDigits(numeric.substring(1))
|| isDigits(numeric))) {
                         try {
                             return createLong(numeric);
                         } catch (NumberFormatException nfe) {

Modified: jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
URL: http://svn.apache.org/viewvc/jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java?view=diff&rev=488819&r1=488818&r2=488819
==============================================================================
--- jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
(original)
+++ jakarta/commons/proper/lang/trunk/src/test/org/apache/commons/lang/math/NumberUtilsTest.java
Tue Dec 19 13:50:04 2006
@@ -1364,5 +1364,11 @@
         assertTrue(NumberUtils.FLOAT_ONE.floatValue() == 1.0f);
         assertTrue(NumberUtils.FLOAT_MINUS_ONE.floatValue() == -1.0f);
     }
+
+    public void testLang300() {
+        NumberUtils.createNumber("-1l");
+        NumberUtils.createNumber("01l");
+        NumberUtils.createNumber("1l");
+    }
     
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message