Skip to content

Commit c45c43b

Browse files
authored
Remove IOException from IonObjectMapper read and write method signatures (#631)
1 parent 49a394f commit c45c43b

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@
1717
import java.io.IOException;
1818
import java.util.Date;
1919

20+
import tools.jackson.core.JacksonException;
2021
import tools.jackson.core.Version;
22+
import tools.jackson.core.exc.JacksonIOException;
2123
import tools.jackson.core.type.TypeReference;
22-
2324
import tools.jackson.databind.JavaType;
2425
import tools.jackson.databind.ObjectMapper;
2526
import tools.jackson.databind.cfg.MapperBuilder;
2627
import tools.jackson.databind.cfg.MapperBuilderState;
2728
import tools.jackson.databind.deser.DeserializationContextExt;
2829
import tools.jackson.databind.module.SimpleModule;
2930
import tools.jackson.databind.ser.SerializationContextExt;
30-
3131
import tools.jackson.dataformat.ion.ionvalue.IonValueModule;
3232

3333
import com.amazon.ion.IonDatagram;
@@ -335,7 +335,7 @@ public IonGenerator createGenerator(IonWriter out) {
335335
* Note: method does not close the underlying reader
336336
*/
337337
@SuppressWarnings("unchecked")
338-
public <T> T readValue(IonReader r, Class<T> valueType) throws IOException {
338+
public <T> T readValue(IonReader r, Class<T> valueType) throws JacksonException {
339339
DeserializationContextExt ctxt = _deserializationContext();
340340
return (T)_readMapAndClose(ctxt, tokenStreamFactory().createParser(ctxt, r),
341341
_typeFactory.constructType(valueType));
@@ -348,7 +348,7 @@ public <T> T readValue(IonReader r, Class<T> valueType) throws IOException {
348348
* Note: method does not close the underlying reader
349349
*/
350350
@SuppressWarnings({ "unchecked", "rawtypes" })
351-
public <T> T readValue(IonReader r, TypeReference valueTypeRef) throws IOException {
351+
public <T> T readValue(IonReader r, TypeReference valueTypeRef) throws JacksonException {
352352
DeserializationContextExt ctxt = _deserializationContext();
353353
return (T)_readMapAndClose(ctxt, tokenStreamFactory().createParser(ctxt, r),
354354
_typeFactory.constructType(valueTypeRef));
@@ -361,7 +361,7 @@ public <T> T readValue(IonReader r, TypeReference valueTypeRef) throws IOExcepti
361361
* Note: method does not close the underlying reader
362362
*/
363363
@SuppressWarnings("unchecked")
364-
public <T> T readValue(IonReader r, JavaType valueType) throws IOException {
364+
public <T> T readValue(IonReader r, JavaType valueType) throws JacksonException {
365365
DeserializationContextExt ctxt = _deserializationContext();
366366
return (T)_readMapAndClose(ctxt, tokenStreamFactory().createParser(ctxt, r), valueType);
367367
}
@@ -370,7 +370,7 @@ public <T> T readValue(IonReader r, JavaType valueType) throws IOException {
370370
* Convenience method for converting Ion value into given value type.
371371
*/
372372
@SuppressWarnings("unchecked")
373-
public <T> T readValue(IonValue value, Class<T> valueType) throws IOException {
373+
public <T> T readValue(IonValue value, Class<T> valueType) throws JacksonException {
374374
if (value == null) {
375375
return null;
376376
}
@@ -383,7 +383,7 @@ public <T> T readValue(IonValue value, Class<T> valueType) throws IOException {
383383
* Convenience method for converting Ion value into given value type.
384384
*/
385385
@SuppressWarnings({ "unchecked", "rawtypes" })
386-
public <T> T readValue(IonValue value, TypeReference valueTypeRef) throws IOException {
386+
public <T> T readValue(IonValue value, TypeReference valueTypeRef) throws JacksonException {
387387
if (value == null) {
388388
return null;
389389
}
@@ -396,7 +396,7 @@ public <T> T readValue(IonValue value, TypeReference valueTypeRef) throws IOExce
396396
* Convenience method for converting Ion value into given value type.
397397
*/
398398
@SuppressWarnings("unchecked")
399-
public <T> T readValue(IonValue value, JavaType valueType) throws IOException {
399+
public <T> T readValue(IonValue value, JavaType valueType) throws JacksonException {
400400
if (value == null) {
401401
return null;
402402
}
@@ -410,7 +410,7 @@ public <T> T readValue(IonValue value, JavaType valueType) throws IOException {
410410
*<p>
411411
* Note: method does not close the underlying writer explicitly
412412
*/
413-
public void writeValue(IonWriter w, Object value) throws IOException {
413+
public void writeValue(IonWriter w, Object value) throws JacksonException {
414414
SerializationContextExt prov = _serializationContext();
415415
_configAndWriteValue(prov,
416416
tokenStreamFactory().createGenerator(prov, w), value);
@@ -419,7 +419,7 @@ public void writeValue(IonWriter w, Object value) throws IOException {
419419
/**
420420
* Method that can be used to map any Java value to an IonValue.
421421
*/
422-
public IonValue writeValueAsIonValue(Object value) throws IOException
422+
public IonValue writeValueAsIonValue(Object value) throws JacksonException
423423
{
424424
// 04-Jan-2017, tatu: Bit of incompatiblity wrt 2.x handling: should this result in
425425
// Java `null`, or Ion null marker? For now, choose latter
@@ -436,6 +436,8 @@ public IonValue writeValueAsIonValue(Object value) throws IOException
436436
IonValue result = container.get(0);
437437
result.removeFromContainer();
438438
return result;
439+
} catch (IOException e) {
440+
throw JacksonIOException.construct(e);
439441
}
440442
}
441443

release-notes/CREDITS

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,8 @@ Andy Wilkinson (@wilkinsona)
2323
* Requested #619: (avro, cbor, ion, smile) Add `isEnabled()` methods for format-specific features
2424
(like `CBORReadFeature` and `CBORWriteFeature`) to mappers
2525
(3.1.0)
26+
27+
Michael Liedtke (@mcliedtke)
28+
29+
* Contributed #629: (ion) Unnecessary `IOException` in `IonObjectMapper` method signatures
30+
(3.1.0)

release-notes/VERSION

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ implementations)
2323
(requested by Andy W)
2424
#623: (ion) Upgrade `ion-java` dep to 1.11.11 (from 1.11.10)
2525
(requested by @Shaurya0108)
26+
#629: (ion) Unnecessary `IOException` in `IonObjectMapper` method signatures
27+
(fix contributed by Michael L)
2628

2729
3.0.1 (21-Oct-2025)
2830

0 commit comments

Comments
 (0)