File tree Expand file tree Collapse file tree 3 files changed +17
-1
lines changed
main/java/tools/jackson/dataformat/ion
test/java/tools/jackson/dataformat/ion Expand file tree Collapse file tree 3 files changed +17
-1
lines changed Original file line number Diff line number Diff line change @@ -328,7 +328,7 @@ private long _getLongValue() throws JacksonException {
328328 try {
329329 if (getNumberType () == NumberType .BIG_INTEGER ) {
330330 BigInteger bigInteger = _reader .bigIntegerValue ();
331- if (BI_MIN_INT .compareTo (bigInteger ) > 0 || BI_MAX_INT .compareTo (bigInteger ) < 0 ) {
331+ if (BI_MIN_LONG .compareTo (bigInteger ) > 0 || BI_MAX_LONG .compareTo (bigInteger ) < 0 ) {
332332 _reportOverflowLong ();
333333 }
334334 return bigInteger .longValue ();
Original file line number Diff line number Diff line change 55import org .hamcrest .Matchers ;
66import org .junit .jupiter .api .Test ;
77
8+ import tools .jackson .core .*;
89import tools .jackson .core .exc .InputCoercionException ;
910
1011import static org .hamcrest .MatcherAssert .assertThat ;
@@ -72,4 +73,16 @@ private void _testLongCoercionFail(BigInteger input) throws Exception
7273 }
7374 }
7475
76+ // [dataformats-binary#569]: incorrect overflow fail for long values (from BigInteger)
77+ @ Test
78+ public void testLongAsBigIntegerSize () throws Exception {
79+ // Note: Values: Long.MAX_VALUE through Long.MAX_VALUE -7 are considered LONG by Ion.
80+ BigInteger bigIntLongValue = new BigInteger (Long .MAX_VALUE + "" ).subtract (BigInteger .TEN );
81+ IonParser bigIntLongParser = (IonParser ) new IonFactory ().createParser (ObjectReadContext .empty (),
82+ 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+ }
7588}
Original file line number Diff line number Diff line change @@ -37,6 +37,9 @@ Active maintainers:
3737
38382.18 .4 (not yet released )
3939
40+ #569 : (ion) `IonParser` fails to parse some `long` values saying
41+ they are out of range when they are not
42+ (reported , fix suggested by @seadbrane )
4043- (ion ) Upgrade `ion - java ` to 1.11 .10 (from 1.11 .9 )
4144
42452.18 .3 (28 - Feb - 2025 )
You can’t perform that action at this time.
0 commit comments