Issue 630 in google-gson: JsonElement's getAsInt() doesn't throw an Error when converting an too big exponential value

7 views
Skip to first unread message

googl...@googlecode.com

unread,
Mar 4, 2015, 9:41:37 AM3/4/15
to google-gson...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 630 by Sebastia...@gmail.com: JsonElement's getAsInt() doesn't
throw an Error when converting an too big exponential value
https://code.google.com/p/google-gson/issues/detail?id=630

What steps will reproduce the problem?
Example:
String json = "{\"id\":1e10000010}";
JsonParser parser = new JsonParser();
JsonObject jsonObj = (JsonObject) parser.parse(json);
Date before = new Date();
Integer Id = jsonObj.get("id").getAsInt();
Date after = new Date();
Long diff = after.getTime() - before.getTime();
System.out.println("Id: " + Id + " Milliseconds: " + diff);

Output: Id: 0 Milliseconds: 9714

What is the expected output? What do you see instead?
It should throw an error, but instead returns 0 after a long time.

What version of the product are you using? On what operating system?
Gson 2.3.1
Ubuntu 14.04

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

googl...@googlecode.com

unread,
Mar 5, 2015, 3:10:42 AM3/5/15
to google-gson...@googlegroups.com

Comment #1 on issue 630 by Sebastia...@gmail.com: JsonElement's getAsInt()
doesn't throw an Error when converting an too big exponential value
https://code.google.com/p/google-gson/issues/detail?id=630

The currently used Java Version is 1.8.0_31
Reply all
Reply to author
Forward
0 new messages