fix for WW-4269

blank double results in NumberFormatException being thrown on sending
JSON in request body
This commit is contained in:
Victor Sosa
2015-12-30 13:36:58 -04:00
parent 30fd44f0ef
commit db483ccd15
@@ -155,6 +155,7 @@ public class JSONReader {
return new JSONException("Input string is not well formed JSON (invalid char " + this.c + ")");
}
@SuppressWarnings("unchecked")
protected List array() throws JSONException {
List ret = new ArrayList();
@@ -174,7 +175,7 @@ public class JSONReader {
return ret;
}
protected Object number() {
protected Object number() throws JSONException {
this.buf.setLength(0);
boolean toDouble = false;
@@ -202,9 +203,17 @@ public class JSONReader {
}
if (toDouble) {
return Double.parseDouble(this.buf.toString());
try {
return Double.parseDouble(this.buf.toString());
} catch (NumberFormatException e) {
throw buildInvalidInputException();
}
} else {
return Long.parseLong(this.buf.toString());
try {
return Long.parseLong(this.buf.toString());
} catch (NumberFormatException e) {
throw buildInvalidInputException();
}
}
}