Play [2.4.2 - Java] Numbers in RequestBody deserialized as BigInteger by default - Bug ?

79 views
Skip to first unread message

Apoorv Reddy

unread,
Jul 22, 2015, 3:17:13 AM7/22/15
to play-framework
Hello,

I've found that numbers in the request body Json are deserialized as BigIntegers by default. I think this is a bug, as I think the default behaviour should be to deserialize integers into Integer by default. The following code is a snippet which illustrates this bug.

public Result testBigInteger(){

JsonNode requestBody = request().body().asJson();
Object x = requestBody.get("number");

if(x instanceof BigIntegerNode){
return ok("Yes");
}
else{
return ok("No");
}
}


And the following is the Post Request that I made to check this, with the returned result.


Евгений Чипаченко

unread,
Jul 23, 2015, 8:16:51 AM7/23/15
to play-framework, are...@cognitivescale.com
Yes, it's really bug.

After upgrading play 2.3.9 to 2.4.2 we have many issue with this bug.

Евгений Чипаченко

unread,
Jul 28, 2015, 3:26:38 AM7/28/15
to play-framework, are...@cognitivescale.com, echipa...@gmail.com
any changes?

Apoorv Reddy

unread,
Jul 28, 2015, 3:44:02 AM7/28/15
to Евгений Чипаченко, play-framework
Hi, 

I do not know if there've been any changes. Currently I am using a hack to get around this issue.

String requestBody = request().body().asJson().toString();
JsonNode requestJson = mapper.readTree(requestBody);

Max Kremer

unread,
Jan 18, 2016, 5:19:06 PM1/18/16
to play-framework
Yes this is a bug. No it wont be fixed:

Greg Methvin

unread,
Jan 19, 2016, 2:42:56 AM1/19/16
to play-framework
Issue 5472 is the actual problem here. It is fixed in Play 2.5.

I don't think the default behavior is necessarily wrong (the specific node types are not documented), but most users would expect to at least be able to configure it as you can with all the other Jackson stuff.

If someone wants to investigate a fix for 2.4 we would welcome it.

Greg
Reply all
Reply to author
Forward
0 new messages