You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the TokenBuffer API I have noticed some unexpected behaviour wrt to 32 bit integers limits when deserializing a constructed TokenBuffer. It seems like when calling getIntValue() where the number value is bigger than the Java integer (32bit) limit might produce a wrong result instead of throwing an exception saying the number is too big. When not using a TokenBuffer parser, but when an implementation of ParserBase is used, I get some expected exceptions saying Numeric value ... out of range of int.
Here's a TokenBuffer example:
TokenBuffertb = newTokenBuffer(newObjectMapper(), false);
tb.writeNumber("-4294967295");
JsonParserjp = tb.asParser();
jp.nextToken();
System.out.println("jp.getIntValue() = " + jp.getIntValue());
// returned value is 1
(using a recent 2.9.1-SNAPSHOT build)
However as you can see here, ParserBase.getIntValue() tries to convert the int, which if not valid fails, and throws the expected exception of int overflow.
Thanks.
The text was updated successfully, but these errors were encountered:
That does sound like a flaw: I think behavior should be identical. One can not rely on generator side of TokenBuffer to guard against it as it is possible to add a long or BigInteger and try to read as int.
Thank you for reporting this.
cowtowncoder
changed the title
Integer bounds verification when calling JsonParser.getIntValue()
Integer bounds verification when calling TokenBuffer.getIntValue()Jan 3, 2018
Hello,
Using the
TokenBuffer
API I have noticed some unexpected behaviour wrt to 32 bit integers limits when deserializing a constructedTokenBuffer
. It seems like when callinggetIntValue()
where the number value is bigger than the Java integer (32bit) limit might produce a wrong result instead of throwing an exception saying the number is too big. When not using aTokenBuffer
parser, but when an implementation ofParserBase
is used, I get some expected exceptions sayingNumeric value ... out of range of int
.Here's a
TokenBuffer
example:(using a recent 2.9.1-SNAPSHOT build)
However as you can see here,
ParserBase.getIntValue()
tries to convert the int, which if not valid fails, and throws the expected exception of int overflow.Thanks.
The text was updated successfully, but these errors were encountered: