File tree Expand file tree Collapse file tree 5 files changed +18
-4
lines changed
main/java/com/fasterxml/jackson/dataformat/ion
test/java/com/fasterxml/jackson/dataformat/ion Expand file tree Collapse file tree 5 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -413,8 +413,8 @@ private long _getLongValue() throws IOException {
413
413
try {
414
414
if (this .getNumberType () == NumberType .BIG_INTEGER ) {
415
415
BigInteger bigInteger = _reader .bigIntegerValue ();
416
- if (BI_MIN_INT .compareTo (bigInteger ) > 0 || BI_MAX_INT .compareTo (bigInteger ) < 0 ) {
417
- this . reportOverflowLong ();
416
+ if (BI_MIN_LONG .compareTo (bigInteger ) > 0 || BI_MAX_LONG .compareTo (bigInteger ) < 0 ) {
417
+ reportOverflowLong ();
418
418
}
419
419
return bigInteger .longValue ();
420
420
} else {
Original file line number Diff line number Diff line change 3
3
import org .hamcrest .Matchers ;
4
4
import org .junit .Test ;
5
5
6
+ import com .fasterxml .jackson .core .JsonParser ;
7
+ import com .fasterxml .jackson .core .JsonToken ;
6
8
import com .fasterxml .jackson .core .exc .InputCoercionException ;
7
9
8
10
import static org .hamcrest .MatcherAssert .assertThat ;
@@ -72,4 +74,15 @@ private void _testLongCoercionFail(BigInteger input) throws Exception
72
74
}
73
75
}
74
76
77
+ // [dataformats-binary#569]: incorrect overflow fail for long values (from BigInteger)
78
+ @ Test
79
+ public void testLongAsBigIntegerSize () throws Exception {
80
+ // Note: Values: Long.MAX_VALUE through Long.MAX_VALUE -7 are considered LONG by Ion.
81
+ BigInteger bigIntLongValue = new BigInteger (Long .MAX_VALUE + "" ).subtract (BigInteger .TEN );
82
+ IonParser bigIntLongParser = (IonParser ) new IonFactory ().createParser (bigIntLongValue .toString ());
83
+ assertEquals (JsonToken .VALUE_NUMBER_INT , bigIntLongParser .nextToken ());
84
+ assertEquals (JsonParser .NumberType .BIG_INTEGER , bigIntLongParser .getNumberType ());
85
+ assertEquals (JsonParser .NumberTypeFP .UNKNOWN , bigIntLongParser .getNumberTypeFP ());
86
+ assertEquals (bigIntLongValue .longValue (), bigIntLongParser .getLongValue ());
87
+ }
75
88
}
Original file line number Diff line number Diff line change 6
6
import com .fasterxml .jackson .core .exc .StreamReadException ;
7
7
import com .fasterxml .jackson .databind .ObjectMapper ;
8
8
import com .fasterxml .jackson .dataformat .ion .*;
9
- import com .fasterxml .jackson .dataformat .ion .fuzz .IonFuzzTestUtil ;
10
9
11
10
import static org .hamcrest .MatcherAssert .assertThat ;
12
11
import static org .junit .Assert .fail ;
Original file line number Diff line number Diff line change 6
6
import com .fasterxml .jackson .core .exc .StreamReadException ;
7
7
import com .fasterxml .jackson .databind .ObjectMapper ;
8
8
import com .fasterxml .jackson .dataformat .ion .*;
9
- import com .fasterxml .jackson .dataformat .ion .fuzz .IonFuzzTestUtil ;
10
9
11
10
import static org .hamcrest .MatcherAssert .assertThat ;
12
11
import static org .junit .Assert .fail ;
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ Active maintainers:
16
16
17
17
2.18 .4 (not yet released )
18
18
19
+ #569 : (ion ) `IonParser ` fails to parse some `long` values saying
20
+ they are out of range when they are not
21
+ (reported , fix suggested by @seadbrane )
19
22
- (ion ) Upgrade `ion - java ` to 1.11 .10 (from 1.11 .9 )
20
23
21
24
2.18 .3 (28 - Feb - 2025 )
You can’t perform that action at this time.
0 commit comments