Skip to content

Commit 21ca6c4

Browse files
committed
Minor post-merge clean up wrt #417
1 parent be8d29e commit 21ca6c4

File tree

5 files changed

+77
-68
lines changed

5 files changed

+77
-68
lines changed

ion/src/main/java/com/fasterxml/jackson/dataformat/ion/IonParser.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -269,17 +269,23 @@ public String getText() throws IOException
269269
if (_currToken != null) { // null only before/after document
270270
switch (_currToken) {
271271
case FIELD_NAME:
272-
return getCurrentName();
272+
return currentName();
273273
case VALUE_STRING:
274274
try {
275+
return _reader.stringValue();
276+
} catch (UnknownSymbolException e) {
275277
// stringValue() will throw an UnknownSymbolException if we're
276278
// trying to get the text for a symbol id that cannot be resolved.
277279
// stringValue() has an assert statement which could throw an
280+
throw _constructError(e.getMessage(), e);
281+
} catch (AssertionError e) {
278282
// AssertionError if we're trying to get the text with a symbol
279283
// id less than or equals to 0.
280-
return _reader.stringValue();
281-
} catch (UnknownSymbolException | AssertionError e) {
282-
throw _constructError(e.getMessage(), e);
284+
String msg = e.getMessage();
285+
if (msg == null) {
286+
msg = "UNKNOWN ROOT CAUSE";
287+
}
288+
throw _constructError("Internal `IonReader` error: "+msg, e);
283289
}
284290
case VALUE_NUMBER_INT:
285291
case VALUE_NUMBER_FLOAT:
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.fasterxml.jackson.dataformat.ion.fuzz;
2+
3+
import static org.hamcrest.MatcherAssert.assertThat;
4+
import static org.junit.Assert.fail;
5+
6+
import org.hamcrest.Matchers;
7+
import org.junit.Test;
8+
9+
import com.fasterxml.jackson.core.exc.StreamReadException;
10+
import com.fasterxml.jackson.dataformat.ion.*;
11+
12+
// [dataformats-binary#417]
13+
public class Fuzz417_64721InvalidIonTest
14+
{
15+
enum EnumFuzz {
16+
A, B, C, D, E;
17+
}
18+
19+
@Test
20+
public void testFuzz64721AssertionException() throws Exception {
21+
IonFactory f = IonFactory
22+
.builderForBinaryWriters()
23+
.enable(IonParser.Feature.USE_NATIVE_TYPE_ID)
24+
.build();
25+
IonObjectMapper mapper = IonObjectMapper.builder(f).build();
26+
try {
27+
mapper.readValue("$0/", EnumFuzz.class);
28+
fail("Should not pass (invalid content)");
29+
} catch (StreamReadException e) {
30+
assertThat(e.getMessage(), Matchers.containsString("Internal `IonReader` error"));
31+
}
32+
}
33+
}

ion/src/test/java/com/fasterxml/jackson/dataformat/ion/fuzz/Fuzz64721InvalidIonTest.java

Lines changed: 0 additions & 27 deletions
This file was deleted.

release-notes/CREDITS-2.x

Lines changed: 31 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -235,58 +235,53 @@ Martin Giannechini (MartinGian@github)
235235
(2.13.0)
236236

237237
Tyler Gregg (tgregg@github)
238-
239-
#325: (ion) Ensure `IonReader` instances created within `IonFactory` are
240-
always resource-managed
241-
(2.14.0)
238+
#325: (ion) Ensure `IonReader` instances created within `IonFactory` are
239+
always resource-managed
240+
(2.14.0)
242241

243242
David Turner (DaveCTurner@github)
244-
245-
#312: (cbor, smile) Short NUL-only keys incorrectly detected as duplicates
246-
(2.14.0)
243+
#312: (cbor, smile) Short NUL-only keys incorrectly detected as duplicates
244+
(2.14.0)
247245

248246
Matthew Pope (popematt@github)
249-
250-
#311: (ion) `IonObjectMapper` does not throw JacksonException for some
251-
invalid Ion
252-
(2.14.0)
247+
#311: (ion) `IonObjectMapper` does not throw JacksonException for some
248+
invalid Ion
249+
(2.14.0)
253250

254251
Szymon Sasin (szysas@github)
255-
256-
#338: (cbor) Use passed "current value" in `writeStartObject()` overload
257-
(2.14.0)
252+
#338: (cbor) Use passed "current value" in `writeStartObject()` overload
253+
(2.14.0)
258254

259255
Dominik Broj (thetric@github)
260-
261-
#341: (ion) Update to Amazon Ion 1.9.5
262-
(2.14.0)
263-
#410: Update `com.amazon.ion:ion-java` to 1.10.5 (from 1.9.5)
264-
(2.16.0)
256+
#341: (ion) Update to Amazon Ion 1.9.5
257+
(2.14.0)
258+
#410: Update `com.amazon.ion:ion-java` to 1.10.5 (from 1.9.5)
259+
(2.16.0)
265260

266261
Brian Harrington (brharrington@github)
267-
268-
* Contributed #342: (smile) Possible performance improvement on jdk9+ for Smile decoding
269-
(2.14.1)
262+
* Contributed #342: (smile) Possible performance improvement on jdk9+ for Smile decoding
263+
(2.14.1)
270264

271265
Nik Everett (nik9000@github)
272-
273-
* Reported #366: `CBORGenerator.writeRawUTF8String()` seems to ignore offset
274-
(2.14.3)
266+
* Reported #366: `CBORGenerator.writeRawUTF8String()` seems to ignore offset
267+
(2.14.3)
275268

276269
Aaron Barany (here-abarany@github)
277-
278-
* Contributed #347: (cbor) Add support for CBOR stringref extension (`CBORGenerator.Feature.STRINGREF`)
279-
(2.15.0)
280-
* Contributed #356: (cbor) Add `CBORGenerat.Feature.WRITE_MINIMAL_DOUBLES` for writing `double`s
281-
as `float`s if safe to do so
282-
(2.15.0)
270+
* Contributed #347: (cbor) Add support for CBOR stringref extension (`CBORGenerator.Feature.STRINGREF`)
271+
(2.15.0)
272+
* Contributed #356: (cbor) Add `CBORGenerat.Feature.WRITE_MINIMAL_DOUBLES` for writing `double`s
273+
as `float`s if safe to do so
274+
(2.15.0)
283275

284276
Kyle Silver (kyle-silver@github)
285-
286-
* Reported *379: (avro) `logback-test.xml` in wrong place (avro/src/main/resources)
287-
(2.15.2)
277+
* Reported *379: (avro) `logback-test.xml` in wrong place (avro/src/main/resources)
278+
(2.15.2)
288279

289280
Simon Daudin (@simondaudin)
281+
* Reported #384: `Smile` decoding issue with `NonBlockingByteArrayParser`, concurrency
282+
(2.15.3)
290283

291-
* Reported #384: `Smile` decoding issue with `NonBlockingByteArrayParser`, concurrency
292-
(2.15.3)
284+
Arthur Chan (@arthurscchan)
285+
* Contributed #417: (ion) `IonReader` classes contain assert statement which could throw
286+
unexpected `AssertionError`
287+
(2.17.0)

release-notes/VERSION-2.x

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ Active maintainers:
1616

1717
2.17.0 (not yet released)
1818

19-
-
19+
#417: (ion) `IonReader` classes contain assert statement which could throw
20+
unexpected `AssertionError`
21+
(contributed by Arthur C)
2022

2123
2.16.0 (15-Nov-2023)
2224

0 commit comments

Comments
 (0)