From 085dbd3835cdc4a1c318f571a940cc31448636a7 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:25:42 +0100 Subject: [PATCH] fixed files form Lang #7 --- .../Lang/7/org/apache/commons/lang3/math/NumberUtils.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/Lang/7/org/apache/commons/lang3/math/NumberUtils.java b/projects/Lang/7/org/apache/commons/lang3/math/NumberUtils.java index d49da7f..064f547 100644 --- a/projects/Lang/7/org/apache/commons/lang3/math/NumberUtils.java +++ b/projects/Lang/7/org/apache/commons/lang3/math/NumberUtils.java @@ -449,9 +449,6 @@ public static Number createNumber(String str) throws NumberFormatException { if (StringUtils.isBlank(str)) { throw new NumberFormatException("A blank string is not a valid number"); } - if (str.startsWith("--")) { - return null; - } if (str.startsWith("0x") || str.startsWith("-0x") || str.startsWith("0X") || str.startsWith("-0X")) { int hexDigits = str.length() - 2; // drop 0x if (str.startsWith("-")) { // drop - @@ -718,10 +715,13 @@ public static BigDecimal createBigDecimal(String str) { if (StringUtils.isBlank(str)) { throw new NumberFormatException("A blank string is not a valid number"); } + if (str.trim().startsWith("--")) { // this is protection for poorness in java.lang.BigDecimal. // it accepts this as a legal value, but it does not appear // to be in specification of class. OS X Java parses it to // a wrong value. + throw new NumberFormatException(str + " is not a valid number."); + } return new BigDecimal(str); }