DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21904>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=21904 NumberUtils.createBigDecimal("") NPE in Sun 1.3.1_08 Summary: NumberUtils.createBigDecimal("") NPE in Sun 1.3.1_08 Product: Commons Version: Nightly Builds Platform: Other OS/Version: Other Status: NEW Severity: Normal Priority: Other Component: Lang AssignedTo: [EMAIL PROTECTED] ReportedBy: [EMAIL PROTECTED] Hello, The NumberUtils.createXXX methods all have the following pattern: public static XXX createXXX(String str) { if (str == null) { return null; } In the case of BigDecimal, passing in a "" to new BigDecimal(String) in Sun 1.3.1_08 blows up like this: java.lang.StringIndexOutOfBoundsException: String index out of range: 0 at java.lang.String.charAt(String.java:582) at java.math.BigDecimal.<init>(BigDecimal.java:124) at org.apache.commons.lang.math.NumberUtils.createBigDecimal(NumberUtils.java:4 78) at org.apache.commons.lang.math.NumberUtilsTest.testCreateBigDecimal(NumberUtil sTest.java:209) Under Sun 1.4.2, you get a NumberFormatException if the length of the string is 0 (no trim()). The unit tests expect a NumberFormatException when you pass in "". So... to make this all nice on 1.3, should all of the guard clauses become: (1) if (StringUtil.isEmpty(str)) { return null; } (2) if (StringUtil.isBlank(str)) { return null; } (3) if (str == null) { return null; } if (StringUtil.isEmpty(str)) { return str; } ? I think (2) would be good since it would not blow up on "" AND " " but I am not familiar with the various invocation contexts, so, please opine. Thanks, Gary --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
