Skip to content

Commit fc07a7a

Browse files
committed
Merge branch '2.19'
2 parents 61dc763 + 4080ae2 commit fc07a7a

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

ion/src/main/java/tools/jackson/dataformat/ion/IonParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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();

ion/src/test/java/tools/jackson/dataformat/ion/IonNumberOverflowTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import org.hamcrest.Matchers;
66
import org.junit.jupiter.api.Test;
77

8+
import tools.jackson.core.*;
89
import tools.jackson.core.exc.InputCoercionException;
910

1011
import 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
}

release-notes/VERSION-2.x

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ Active maintainers:
3737

3838
2.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

4245
2.18.3 (28-Feb-2025)

0 commit comments

Comments
 (0)