Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ private long _getLongValue() throws IOException {
try {
if (this.getNumberType() == NumberType.BIG_INTEGER) {
BigInteger bigInteger = _reader.bigIntegerValue();
if (BI_MIN_INT.compareTo(bigInteger) > 0 || BI_MAX_INT.compareTo(bigInteger) < 0) {
this.reportOverflowLong();
if (BI_MIN_LONG.compareTo(bigInteger) > 0 || BI_MAX_LONG.compareTo(bigInteger) < 0) {
reportOverflowLong();
}
return bigInteger.longValue();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import org.hamcrest.Matchers;
import org.junit.Test;

import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.exc.InputCoercionException;

import static org.hamcrest.MatcherAssert.assertThat;
Expand Down Expand Up @@ -72,4 +74,15 @@ private void _testLongCoercionFail(BigInteger input) throws Exception
}
}

// [dataformats-binary#569]: incorrect overflow fail for long values (from BigInteger)
@Test
public void testLongAsBigIntegerSize() throws Exception {
// Note: Values: Long.MAX_VALUE through Long.MAX_VALUE -7 are considered LONG by Ion.
BigInteger bigIntLongValue = new BigInteger(Long.MAX_VALUE + "").subtract(BigInteger.TEN);
IonParser bigIntLongParser = (IonParser) new IonFactory().createParser(bigIntLongValue.toString());
assertEquals(JsonToken.VALUE_NUMBER_INT, bigIntLongParser.nextToken());
assertEquals(JsonParser.NumberType.BIG_INTEGER, bigIntLongParser.getNumberType());
assertEquals(JsonParser.NumberTypeFP.UNKNOWN, bigIntLongParser.getNumberTypeFP());
assertEquals(bigIntLongValue.longValue(), bigIntLongParser.getLongValue());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.ion.*;
import com.fasterxml.jackson.dataformat.ion.fuzz.IonFuzzTestUtil;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.fasterxml.jackson.core.exc.StreamReadException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.ion.*;
import com.fasterxml.jackson.dataformat.ion.fuzz.IonFuzzTestUtil;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.fail;
Expand Down
3 changes: 3 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Active maintainers:

2.18.4 (not yet released)

#569: (ion) `IonParser` fails to parse some `long` values saying
they are out of range when they are not
(reported, fix suggested by @seadbrane)
- (ion) Upgrade `ion-java` to 1.11.10 (from 1.11.9)

2.18.3 (28-Feb-2025)
Expand Down