Integer.parseInt throws a JavaScript Exception when passed null. The Number.__parseAndValidateLong method
calls s.length (where "s" is the string) without checking if "s" is null. The problem only occurs in non-hosted mode, as
we use the Java version of the Number class in hosted mode.
Change:
I took levikcom's suggestion and added a conditional to check if "s" is null at the beginning of the __parseAndValidateLong
method in the Number class. If it is null, we throw a NumberFormatException with the message "Unable to parse null".
Issue: 1317
Found by: levikcom
Fixed by: jlabanca
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1240 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/super/com/google/gwt/emul/java/lang/Number.java b/user/super/com/google/gwt/emul/java/lang/Number.java
index c848490..d4260a2 100644
--- a/user/super/com/google/gwt/emul/java/lang/Number.java
+++ b/user/super/com/google/gwt/emul/java/lang/Number.java
@@ -91,6 +91,9 @@
protected static long __parseAndValidateLong(String s, int radix,
long lowerBound, long upperBound) throws NumberFormatException {
+ if (s == null) {
+ throw new NumberFormatException("Unable to parse null");
+ }
int length = s.length();
int startIndex = (length > 0) && (s.charAt(0) == '-') ? 1 : 0;