-
-
Couldn't load subscription status.
- Fork 149
Description
In some cases, the IonObjectMapper is not correctly catching and wrapping IonExceptions. For example, given this class:
class FooBar {
int foo;
List<Object> bar;
}When attempting to deserialize invalid Ion, sometimes we get a JsonMappingException, and other times an IonException.
IonObjectMapper mapper = IonObjectMapper.builder().build();
// throws a JsonMappingException
FooBar fb1 = mapper.readValue("{ foo: 1, bar: () ] }", FooBar.class);
// throws an IonException
FooBar fb1 = mapper.readValue("{ foo: 1, bar: ( ] ) }", FooBar.class); Why does this matter? Some other libraries (eg. Ktor, in the JacksonConverter) expect particular exceptions (eg. JsonParseException or JsonMappingException) from an ObjectMapper, and behave in unexpected ways when the IonException leaks through.
I believe the fix for this is to catch and wrap IonException as a JsonParseException in the IonParser.nextToken() method, and I intend to work on a PR for it.