Skip to content

Commit

Permalink
Fixed #2393
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jul 26, 2019
1 parent 94301a8 commit 2c4a105
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Project: jackson-databind

#2331: `JsonMappingException` through nested getter with generic wildcard return type
(reported by sunchezz89@github)
#2393: `TreeTraversingParser.getLongValue()` incorrectly checks `canConvertToInt()`
(reported by RabbidDog@github)

2.10.0.pr1 (19-Jul-2019)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ public int getIntValue() throws IOException {
@Override
public long getLongValue() throws IOException {
final NumericNode node = (NumericNode) currentNumericNode();
if (!node.canConvertToInt()) {
if (!node.canConvertToLong()) {
reportOverflowLong();
}
return node.longValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,5 +350,19 @@ public void testNumberOverflowLong() throws IOException
verifyException(e, "Numeric value ("+tooBig2+") out of range of long");
}
}

// Plus, wrt [databind#2393], NON-failing cases
final long[] okValues = new long[] { 1L+Integer.MAX_VALUE, -1L + Integer.MIN_VALUE,
Long.MAX_VALUE, Long.MIN_VALUE };
for (long okValue : okValues) {
try (final JsonParser p = MAPPER.readTree("{ \"value\" : "+okValue+" }").traverse()) {
assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(NumberType.LONG, p.getNumberType());
assertEquals(okValue, p.getLongValue());
assertToken(JsonToken.END_OBJECT, p.nextToken());
}
}
}
}

0 comments on commit 2c4a105

Please sign in to comment.