From 16200452b90d9cfa7f3a96b91b55afb8fcf34434 Mon Sep 17 00:00:00 2001 From: Tatu Saloranta Date: Sat, 16 Jan 2021 13:05:25 -0800 Subject: [PATCH] More #2177 work, now under 100 errors --- .../deser/impl/BeanAsArrayDeserializer.java | 14 +++---- .../deser/impl/TypeWrappedDeserializer.java | 9 ++-- .../databind/deser/std/EnumDeserializer.java | 13 +++--- .../databind/ext/SqlBlobSerializer.java | 9 ++-- .../ext/XMLGregorianCalendarSerializer.java | 9 ++-- .../ext/jdk8/DoubleStreamSerializer.java | 25 ++++------- .../ext/jdk8/IntStreamSerializer.java | 21 ++++------ .../ext/jdk8/Jdk8StreamSerializer.java | 26 ++++-------- .../ext/jdk8/LongStreamSerializer.java | 22 ++++------ .../ext/jdk8/OptionalDoubleDeserializer.java | 6 ++- .../ext/jdk8/OptionalDoubleSerializer.java | 9 ++-- .../ext/jdk8/OptionalIntDeserializer.java | 7 +++- .../ext/jdk8/OptionalIntSerializer.java | 9 ++-- .../ext/jdk8/OptionalLongDeserializer.java | 5 ++- .../ext/jdk8/OptionalLongSerializer.java | 10 ++--- .../jackson/databind/ser/BeanSerializer.java | 4 +- .../databind/ser/UnrolledBeanSerializer.java | 7 ++-- .../ser/impl/BeanAsArraySerializer.java | 17 ++++---- .../databind/ser/impl/FailingSerializer.java | 6 +-- .../databind/ser/impl/IteratorSerializer.java | 11 +++-- .../ser/impl/StringArraySerializer.java | 11 +++-- .../ser/impl/StringCollectionSerializer.java | 8 ++-- .../ser/impl/TypeWrappedSerializer.java | 7 ++-- .../databind/ser/impl/UnknownSerializer.java | 7 ++-- .../impl/UnrolledBeanAsArraySerializer.java | 8 ++-- .../ser/impl/UnsupportedTypeSerializer.java | 4 +- .../ser/impl/UnwrappingBeanSerializer.java | 10 ++--- .../databind/ser/std/BooleanSerializer.java | 42 ++++++++++--------- .../databind/ser/std/CalendarSerializer.java | 5 ++- .../databind/ser/std/DateSerializer.java | 4 +- .../ser/std/DateTimeSerializerBase.java | 11 ++--- .../databind/ser/std/EnumSerializer.java | 3 +- .../ser/std/InetSocketAddressSerializer.java | 9 ++-- .../databind/ser/std/IterableSerializer.java | 6 +-- .../databind/ser/std/RawSerializer.java | 9 ++-- .../ser/std/ReferenceTypeSerializer.java | 14 +++---- .../ser/std/SerializableSerializer.java | 12 +++--- .../databind/ser/std/SqlDateSerializer.java | 4 +- .../databind/ser/std/SqlTimeSerializer.java | 8 ++-- .../ser/std/StaticListSerializerBase.java | 5 +-- .../databind/ser/std/StdArraySerializers.java | 31 +++++++------- .../ser/std/StdDelegatingSerializer.java | 23 +++++----- .../databind/ser/std/StdJdkSerializers.java | 12 +++--- .../databind/ser/std/StdKeySerializers.java | 13 +++--- .../databind/ser/std/StdScalarSerializer.java | 8 ++-- .../ser/std/StringLikeSerializer.java | 7 ++-- .../databind/ser/std/StringSerializer.java | 12 +++--- .../databind/ser/std/TimeZoneSerializer.java | 10 +++-- .../ser/std/ToStringSerializerBase.java | 11 +++-- .../ser/std/TokenBufferSerializer.java | 12 +++--- .../databind/ser/std/UUIDSerializer.java | 13 ++---- 51 files changed, 272 insertions(+), 306 deletions(-) diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanAsArrayDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanAsArrayDeserializer.java index a840a6b092..233611e5de 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanAsArrayDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/BeanAsArrayDeserializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.deser.impl; -import java.io.IOException; import java.util.Set; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.databind.*; @@ -96,7 +96,7 @@ protected void initFieldMatcher(DeserializationContext ctxt) { } @Override public Object deserialize(JsonParser p, DeserializationContext ctxt) - throws IOException + throws JacksonException { // Let's delegate just in case we got a JSON Object (could error out, alternatively?) if (!p.isExpectedStartArrayToken()) { @@ -244,7 +244,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) @Override public Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean) - throws IOException + throws JacksonException { // [databind#631]: Assign current value, to be accessible by custom serializers p.setCurrentValue(bean); @@ -299,7 +299,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt, Object bean // needed since 2.1 @Override public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) - throws IOException + throws JacksonException { return _deserializeFromNonArray(p, ctxt); } @@ -315,7 +315,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) * aspects than the "vanilla" processing. */ protected Object _deserializeNonVanilla(JsonParser p, DeserializationContext ctxt) - throws IOException + throws JacksonException { if (_nonStandardCreation) { return deserializeFromObjectUsingNonDefault(p, ctxt); @@ -377,7 +377,7 @@ protected Object _deserializeNonVanilla(JsonParser p, DeserializationContext ctx */ @Override protected final Object _deserializeUsingPropertyBased(final JsonParser p, final DeserializationContext ctxt) - throws IOException + throws JacksonException { final PropertyBasedCreator creator = _propertyBasedCreator; PropertyValueBuffer buffer = creator.startBuilding(p, ctxt, _objectIdReader); @@ -463,7 +463,7 @@ protected final Object _deserializeUsingPropertyBased(final JsonParser p, final */ protected Object _deserializeFromNonArray(JsonParser p, DeserializationContext ctxt) - throws IOException + throws JacksonException { return ctxt.handleUnexpectedToken(getValueType(ctxt), p.currentToken(), p, "Cannot deserialize a POJO (of type %s) from non-Array representation (token: %s): " diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/impl/TypeWrappedDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/impl/TypeWrappedDeserializer.java index f2045913ae..e574df7de1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/impl/TypeWrappedDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/impl/TypeWrappedDeserializer.java @@ -1,9 +1,10 @@ package com.fasterxml.jackson.databind.deser.impl; -import java.io.IOException; import java.util.Collection; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonParser; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsontype.TypeDeserializer; import com.fasterxml.jackson.databind.type.LogicalType; @@ -66,14 +67,14 @@ public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingExcep } @Override - public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException + public Object deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException { return _deserializer.deserializeWithType(p, ctxt, _typeDeserializer); } @Override public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, - TypeDeserializer typeDeserializer) throws IOException + TypeDeserializer typeDeserializer) throws JacksonException { // should never happen? (if it can, could call on that object) throw new IllegalStateException("Type-wrapped deserializer's deserializeWithType should never get called"); @@ -81,7 +82,7 @@ public Object deserializeWithType(JsonParser p, DeserializationContext ctxt, @Override public Object deserialize(JsonParser p, DeserializationContext ctxt, - Object intoValue) throws IOException + Object intoValue) throws JacksonException { /* 01-Mar-2013, tatu: Hmmh. Tough call as to what to do... need * to delegate, but will this work reliably? Let's just hope so: diff --git a/src/main/java/com/fasterxml/jackson/databind/deser/std/EnumDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/deser/std/EnumDeserializer.java index 8a2f68108b..e522aa0269 100644 --- a/src/main/java/com/fasterxml/jackson/databind/deser/std/EnumDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/deser/std/EnumDeserializer.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.deser.std; -import java.io.IOException; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonFormat; @@ -137,7 +136,7 @@ public Object getEmptyValue(DeserializationContext ctxt) throws JsonMappingExcep } @Override - public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException + public Object deserialize(JsonParser p, DeserializationContext ctxt) throws JacksonException { // Usually should just get string value: // 04-Sep-2020, tatu: for 2.11.3 / 2.12.0, removed "FIELD_NAME" as allowed; @@ -161,7 +160,7 @@ public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx protected Object _fromString(JsonParser p, DeserializationContext ctxt, String text) - throws IOException + throws JacksonException { CompactStringObjectMap lookup = ctxt.isEnabled(DeserializationFeature.READ_ENUMS_USING_TO_STRING) ? _getToStringLookup(ctxt) : _lookupByName; @@ -177,7 +176,7 @@ protected Object _fromString(JsonParser p, DeserializationContext ctxt, protected Object _fromInteger(JsonParser p, DeserializationContext ctxt, int index) - throws IOException + throws JacksonException { final CoercionAction act = ctxt.findCoercionAction(logicalType(), handledType(), CoercionInputShape.Integer); @@ -227,7 +226,8 @@ protected Object _fromInteger(JsonParser p, DeserializationContext ctxt, */ private final Object _deserializeAltString(JsonParser p, DeserializationContext ctxt, - CompactStringObjectMap lookup, String nameOrig) throws IOException + CompactStringObjectMap lookup, String nameOrig) + throws JacksonException { String name = nameOrig.trim(); if (name.isEmpty()) { // empty or blank @@ -288,7 +288,8 @@ private final Object _deserializeAltString(JsonParser p, DeserializationContext return null; } - protected Object _deserializeOther(JsonParser p, DeserializationContext ctxt) throws IOException + protected Object _deserializeOther(JsonParser p, DeserializationContext ctxt) + throws JacksonException { // [databind#381] if (p.hasToken(JsonToken.START_ARRAY)) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/SqlBlobSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/SqlBlobSerializer.java index b2619460c2..14d344c036 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/SqlBlobSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/SqlBlobSerializer.java @@ -1,10 +1,10 @@ package com.fasterxml.jackson.databind.ext; -import java.io.IOException; import java.io.InputStream; import java.sql.Blob; import java.sql.SQLException; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.WritableTypeId; @@ -40,7 +40,7 @@ public boolean isEmpty(SerializerProvider provider, Blob value) { @Override public void serialize(Blob value, JsonGenerator gen, SerializerProvider ctxt) - throws IOException { + throws JacksonException { _writeValue(value, gen, ctxt); } @@ -48,7 +48,7 @@ public void serialize(Blob value, JsonGenerator gen, SerializerProvider ctxt) @Override public void serializeWithType(Blob value, JsonGenerator gen, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { // most likely scalar WritableTypeId typeIdDef = typeSer.writeTypePrefix(gen, ctxt, @@ -58,7 +58,7 @@ public void serializeWithType(Blob value, JsonGenerator gen, SerializerProvider } protected void _writeValue(Blob value, JsonGenerator gen, SerializerProvider ctxt) - throws IOException + throws JacksonException { InputStream in = null; try { @@ -73,7 +73,6 @@ protected void _writeValue(Blob value, JsonGenerator gen, SerializerProvider ctx // Copied from `com.fasterxml.jackson.databind.ser.std.ByteArraySerializer` @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) - throws JsonMappingException { // 08-Nov-2020, tatu: Same problem as for `byte[]`... should // make work either as String/base64, or array of numbers, diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/XMLGregorianCalendarSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/XMLGregorianCalendarSerializer.java index c5f69156d2..8f813d9673 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/XMLGregorianCalendarSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/XMLGregorianCalendarSerializer.java @@ -1,10 +1,10 @@ package com.fasterxml.jackson.databind.ext; -import java.io.IOException; import java.util.Calendar; import javax.xml.datatype.XMLGregorianCalendar; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.JavaType; @@ -39,19 +39,20 @@ public JsonSerializer getDelegatee() { } @Override - public boolean isEmpty(SerializerProvider provider, XMLGregorianCalendar value) throws IOException { + public boolean isEmpty(SerializerProvider provider, XMLGregorianCalendar value) { return _delegate.isEmpty(provider, _convert(value)); } @Override public void serialize(XMLGregorianCalendar value, JsonGenerator gen, SerializerProvider provider) - throws IOException { + throws JacksonException + { _delegate.serialize(_convert(value), gen, provider); } @Override public void serializeWithType(XMLGregorianCalendar value, JsonGenerator gen, SerializerProvider provider, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) throws JacksonException { _delegate.serializeWithType(_convert(value), gen, provider, typeSer); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/DoubleStreamSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/DoubleStreamSerializer.java index 84493a9d3e..c0f859afbb 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/DoubleStreamSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/DoubleStreamSerializer.java @@ -1,13 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; +import java.util.stream.DoubleStream; + +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.stream.DoubleStream; - /** * {@link DoubleStream} serializer *

@@ -22,28 +21,20 @@ public class DoubleStreamSerializer extends StdSerializer */ public static final DoubleStreamSerializer INSTANCE = new DoubleStreamSerializer(); - /** - * Constructor - */ private DoubleStreamSerializer() { super(DoubleStream.class); } @Override - public void serialize(DoubleStream stream, JsonGenerator g, SerializerProvider provider) throws IOException { - - try(DoubleStream ds = stream) { + public void serialize(DoubleStream stream, JsonGenerator g, SerializerProvider provider) + throws JacksonException + { + try (DoubleStream ds = stream) { g.writeStartArray(ds); ds.forEach(value -> { - try { - g.writeNumber(value); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + g.writeNumber(value); }); g.writeEndArray(); - } catch (UncheckedIOException e) { - throw e.getCause(); } } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/IntStreamSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/IntStreamSerializer.java index a263bdcf7d..d48838c082 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/IntStreamSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/IntStreamSerializer.java @@ -1,14 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; +import java.util.stream.IntStream; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.stream.IntStream; - /** * {@link IntStream} serializer *

@@ -30,21 +28,16 @@ private IntStreamSerializer() { } @Override - public void serialize(IntStream stream, JsonGenerator g, SerializerProvider provider) throws IOException { - - try(IntStream is = stream) { + public void serialize(IntStream stream, JsonGenerator g, SerializerProvider provider) + throws JacksonException + { + try (IntStream is = stream) { g.writeStartArray(is); is.forEach(value -> { - try { - g.writeNumber(value); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + g.writeNumber(value); }); g.writeEndArray(); - } catch (UncheckedIOException e) { - throw e.getCause(); } } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/Jdk8StreamSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/Jdk8StreamSerializer.java index 6319d22ac7..788f838514 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/Jdk8StreamSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/Jdk8StreamSerializer.java @@ -1,13 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; +import java.util.stream.Stream; + +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.stream.Stream; - /** * Common typed stream serializer * @@ -49,7 +48,6 @@ public Jdk8StreamSerializer(JavaType streamType, JavaType elemType, JsonSerializ @Override public JsonSerializer createContextual(SerializerProvider provider, BeanProperty property) - throws JsonMappingException { if (!elemType.hasRawClass(Object.class) && (provider.isEnabled(MapperFeature.USE_STATIC_TYPING) || elemType.isFinal())) { @@ -63,25 +61,19 @@ public JsonSerializer createContextual(SerializerProvider provider, BeanPrope @Override public void serialize(Stream stream, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { - try(Stream s = stream) { + try (Stream s = stream) { g.writeStartArray(s); s.forEach(elem -> { - try { - if (elemSerializer == null) { - provider.writeValue(g, elem); - } else { - elemSerializer.serialize(elem, g, provider); - } - } catch (IOException e) { - throw new UncheckedIOException(e); + if (elemSerializer == null) { + provider.writeValue(g, elem); + } else { + elemSerializer.serialize(elem, g, provider); } }); g.writeEndArray(); - } catch (UncheckedIOException e) { - throw e.getCause(); } } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/LongStreamSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/LongStreamSerializer.java index 3f348b64b4..b59196fcad 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/LongStreamSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/LongStreamSerializer.java @@ -1,13 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; +import java.util.stream.LongStream; + +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.ser.std.StdSerializer; -import java.io.IOException; -import java.io.UncheckedIOException; -import java.util.stream.LongStream; - /** * {@link LongStream} serializer *

@@ -21,27 +20,20 @@ public class LongStreamSerializer extends StdSerializer */ public static final LongStreamSerializer INSTANCE = new LongStreamSerializer(); - /** - * Constructor - */ private LongStreamSerializer() { super(LongStream.class); } @Override - public void serialize(LongStream stream, JsonGenerator g, SerializerProvider provider) throws IOException { + public void serialize(LongStream stream, JsonGenerator g, SerializerProvider provider) + throws JacksonException + { try (LongStream ls = stream) { g.writeStartArray(ls); ls.forEach(value -> { - try { - g.writeNumber(value); - } catch (IOException e) { - throw new UncheckedIOException(e); - } + g.writeNumber(value); }); g.writeEndArray(); - } catch (UncheckedIOException e) { - throw e.getCause(); } } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleDeserializer.java index a5124f41e2..456a68efd6 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleDeserializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ext.jdk8; -import java.io.IOException; import java.util.OptionalDouble; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.JsonTokenId; @@ -23,7 +23,9 @@ public OptionalDoubleDeserializer() { public LogicalType logicalType() { return LogicalType.Float; } @Override - public OptionalDouble deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OptionalDouble deserialize(JsonParser p, DeserializationContext ctxt) + throws JacksonException + { // minor optimization, first, for common case if (p.hasToken(JsonToken.VALUE_NUMBER_FLOAT)) { return OptionalDouble.of(p.getDoubleValue()); diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleSerializer.java index c5e598c930..dae8dbc114 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalDoubleSerializer.java @@ -1,12 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; -import java.io.IOException; import java.util.OptionalDouble; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; + import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonNumberFormatVisitor; @@ -27,7 +27,8 @@ public boolean isEmpty(SerializerProvider provider, OptionalDouble value) { @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, - JavaType typeHint) throws JsonMappingException { + JavaType typeHint) + { JsonNumberFormatVisitor v2 = visitor.expectNumberFormat(typeHint); if (v2 != null) { v2.numberType(JsonParser.NumberType.DOUBLE); @@ -36,7 +37,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, @Override public void serialize(OptionalDouble value, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { if (value.isPresent()) { gen.writeNumber(value.getAsDouble()); diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntDeserializer.java index ffac08c095..cfa751c4e1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntDeserializer.java @@ -1,11 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; -import java.io.IOException; import java.util.OptionalInt; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.JsonTokenId; + import com.fasterxml.jackson.databind.DeserializationContext; import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.cfg.CoercionAction; @@ -23,7 +24,9 @@ public OptionalIntDeserializer() { public LogicalType logicalType() { return LogicalType.Integer; } @Override - public OptionalInt deserialize(JsonParser p, DeserializationContext ctxt) throws IOException { + public OptionalInt deserialize(JsonParser p, DeserializationContext ctxt) + throws JacksonException + { // minor optimization, first, for common case if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { return OptionalInt.of(p.getIntValue()); diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntSerializer.java index 22c1f51af3..0b31598661 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalIntSerializer.java @@ -1,12 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; -import java.io.IOException; import java.util.OptionalInt; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; + import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; @@ -25,7 +25,8 @@ public boolean isEmpty(SerializerProvider provider, OptionalInt value) { @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, - JavaType typeHint) throws JsonMappingException { + JavaType typeHint) + { JsonIntegerFormatVisitor v2 = visitor .expectIntegerFormat(typeHint); if (v2 != null) { @@ -35,7 +36,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, @Override public void serialize(OptionalInt value, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { if (value.isPresent()) { gen.writeNumber(value.getAsInt()); diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongDeserializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongDeserializer.java index 8de0f1d061..ef6058bddd 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongDeserializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongDeserializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ext.jdk8; -import java.io.IOException; import java.util.OptionalLong; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.JsonTokenId; @@ -23,7 +23,8 @@ public OptionalLongDeserializer() { public LogicalType logicalType() { return LogicalType.Integer; } @Override - public OptionalLong deserialize(JsonParser p, DeserializationContext ctxt) throws IOException + public OptionalLong deserialize(JsonParser p, DeserializationContext ctxt) + throws JacksonException { // minor optimization, first, for common case if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongSerializer.java index dd9d0a3053..3df946918d 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ext/jdk8/OptionalLongSerializer.java @@ -1,12 +1,12 @@ package com.fasterxml.jackson.databind.ext.jdk8; -import java.io.IOException; import java.util.OptionalLong; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; + import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonIntegerFormatVisitor; @@ -20,7 +20,6 @@ public OptionalLongSerializer() { super(OptionalLong.class); } - // @since 2.6 @Override public boolean isEmpty(SerializerProvider provider, OptionalLong value) { return (value == null) || !value.isPresent(); @@ -28,7 +27,8 @@ public boolean isEmpty(SerializerProvider provider, OptionalLong value) { @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, - JavaType typeHint) throws JsonMappingException { + JavaType typeHint) + { JsonIntegerFormatVisitor v2 = visitor .expectIntegerFormat(typeHint); if (v2 != null) { @@ -38,7 +38,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, @Override public void serialize(OptionalLong value, JsonGenerator jgen, SerializerProvider provider) - throws IOException + throws JacksonException { if (value.isPresent()) { jgen.writeNumber(value.getAsLong()); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializer.java index 5ed924d65d..1941147aeb 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/BeanSerializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ser; -import java.io.IOException; import java.util.Set; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; @@ -144,7 +144,7 @@ protected BeanSerializerBase asArraySerializer() */ @Override public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { if (_objectIdWriter != null) { _serializeWithObjectId(bean, gen, provider, true); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/UnrolledBeanSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/UnrolledBeanSerializer.java index 8e739093ad..9ef8414c25 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/UnrolledBeanSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/UnrolledBeanSerializer.java @@ -1,9 +1,10 @@ package com.fasterxml.jackson.databind.ser; -import java.io.IOException; import java.util.Set; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.ser.impl.BeanAsArraySerializer; @@ -158,7 +159,7 @@ public void resolve(SerializerProvider provider) throws JsonMappingException @Override public void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { // NOTE! We have ensured that "JSON Filter" and "Object Id" cases // always use "vanilla" BeanSerializer, so no need to check here @@ -174,7 +175,7 @@ public void serialize(Object bean, JsonGenerator gen, SerializerProvider provide } protected void serializeNonFiltered(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { gen.writeStartObject(bean); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/BeanAsArraySerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/BeanAsArraySerializer.java index 927e5cb025..faef122271 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/BeanAsArraySerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/BeanAsArraySerializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; import java.util.Set; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.WritableTypeId; @@ -143,7 +143,7 @@ protected BeanSerializerBase asArraySerializer() { @Override public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { // 10-Dec-2014, tatu: Not sure if this can be made to work reliably; // but for sure delegating to default implementation will not work. So: @@ -155,8 +155,11 @@ public void serializeWithType(Object bean, JsonGenerator gen, WritableTypeId typeIdDef = _typeIdDef(typeSer, bean, JsonToken.START_ARRAY); typeSer.writeTypePrefix(gen, ctxt, typeIdDef); final boolean filtered = (_filteredProps != null && ctxt.getActiveView() != null); - if (filtered) serializeFiltered(bean, gen, ctxt); - else serializeNonFiltered(bean, gen, ctxt); + if (filtered) { + serializeFiltered(bean, gen, ctxt); + } else { + serializeNonFiltered(bean, gen, ctxt); + } typeSer.writeTypeSuffix(gen, ctxt, typeIdDef); } @@ -167,7 +170,7 @@ public void serializeWithType(Object bean, JsonGenerator gen, */ @Override public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { final boolean filtered = (_filteredProps != null && provider.getActiveView() != null); if (provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED) @@ -198,7 +201,7 @@ private boolean hasSingleElement(SerializerProvider provider) { protected final void serializeNonFiltered(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { final BeanPropertyWriter[] props = _props; int i = 0; @@ -245,7 +248,7 @@ protected final void serializeNonFiltered(Object bean, JsonGenerator gen, } protected final void serializeFiltered(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { final BeanPropertyWriter[] props = _filteredProps; int i = 0; diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/FailingSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/FailingSerializer.java index 5d1cc9fb6f..6951f5f69e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/FailingSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/FailingSerializer.java @@ -1,7 +1,5 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JsonMappingException; @@ -26,7 +24,9 @@ public FailingSerializer(String msg) { } @Override - public void serialize(Object value, JsonGenerator g, SerializerProvider provider) throws IOException { + public void serialize(Object value, JsonGenerator g, SerializerProvider provider) + throws JacksonException + { provider.reportMappingProblem(_msg); } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java index 17c6a4389a..ea6d31fa2b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/IteratorSerializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; import java.util.Iterator; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; @@ -55,7 +55,8 @@ public boolean hasSingleElement(Iterator value) { @Override public final void serialize(Iterator value, JsonGenerator gen, - SerializerProvider provider) throws IOException + SerializerProvider provider) + throws JacksonException { // 02-Dec-2016, tatu: As per comments above, can't determine single element so... /* @@ -75,7 +76,8 @@ public final void serialize(Iterator value, JsonGenerator gen, @Override public void serializeContents(Iterator value, JsonGenerator g, - SerializerProvider provider) throws IOException + SerializerProvider provider) + throws JacksonException { if (!value.hasNext()) { return; @@ -99,7 +101,8 @@ public void serializeContents(Iterator value, JsonGenerator g, } protected void _serializeDynamicContents(Iterator value, JsonGenerator g, - SerializerProvider ctxt) throws IOException + SerializerProvider ctxt) + throws JacksonException { final TypeSerializer typeSer = _valueTypeSerializer; do { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java index ac7c2d1657..3b254f7e1d 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringArraySerializer.java @@ -1,10 +1,9 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonFormat; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -152,7 +151,7 @@ public boolean hasSingleElement(String[] value) { @Override public final void serialize(String[] value, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { final int len = value.length; if (len == 1) { @@ -170,7 +169,7 @@ public final void serialize(String[] value, JsonGenerator gen, SerializerProvide @Override public void serializeContents(String[] value, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { final int len = value.length; if (len == 0) { @@ -191,7 +190,7 @@ public void serializeContents(String[] value, JsonGenerator gen, SerializerProvi } private void serializeContentsSlow(String[] value, JsonGenerator gen, SerializerProvider provider, JsonSerializer ser) - throws IOException + throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { String str = value[i]; @@ -204,7 +203,7 @@ private void serializeContentsSlow(String[] value, JsonGenerator gen, Serializer } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { visitArrayFormat(visitor, typeHint, JsonFormatTypes.STRING); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java index 6473077730..da05b33ec1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/StringCollectionSerializer.java @@ -1,10 +1,10 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.type.WritableTypeId; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonArrayFormatVisitor; @@ -64,7 +64,7 @@ protected void acceptContentVisitor(JsonArrayFormatVisitor visitor) throws JsonM @Override public void serialize(Collection value, JsonGenerator g, - SerializerProvider provider) throws IOException + SerializerProvider provider) throws JacksonException { final int len = value.size(); if (len == 1) { @@ -83,7 +83,7 @@ public void serialize(Collection value, JsonGenerator g, @Override public void serializeWithType(Collection value, JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, ctxt, typeSer.typeId(value, JsonToken.START_ARRAY)); @@ -94,7 +94,7 @@ public void serializeWithType(Collection value, JsonGenerator g, private final void serializeContents(Collection value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { int i = 0; diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/TypeWrappedSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/TypeWrappedSerializer.java index 5186dfd5a9..07d571103b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/TypeWrappedSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/TypeWrappedSerializer.java @@ -1,7 +1,6 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -26,13 +25,13 @@ public TypeWrappedSerializer(TypeSerializer typeSer, JsonSerializer ser) } @Override - public void serialize(Object value, JsonGenerator g, SerializerProvider provider) throws IOException { + public void serialize(Object value, JsonGenerator g, SerializerProvider provider) throws JacksonException { _serializer.serializeWithType(value, g, provider, _typeSerializer); } @Override public void serializeWithType(Object value, JsonGenerator g, SerializerProvider provider, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) throws JacksonException { // Is this an erroneous call? For now, let's assume it is not, and // that type serializer is just overridden if so diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnknownSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnknownSerializer.java index d62fc2db36..0655ae4a39 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnknownSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnknownSerializer.java @@ -1,9 +1,8 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.type.WritableTypeId; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -21,7 +20,7 @@ public UnknownSerializer(Class cls) { } @Override - public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException + public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws JacksonException { // 27-Nov-2009, tatu: As per [JACKSON-201] may or may not fail... if (provider.isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)) { @@ -34,7 +33,7 @@ public void serialize(Object value, JsonGenerator gen, SerializerProvider provid @Override public final void serializeWithType(Object value, JsonGenerator gen, SerializerProvider ctxt, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) throws JacksonException { if (ctxt.isEnabled(SerializationFeature.FAIL_ON_EMPTY_BEANS)) { failForEmpty(ctxt, value); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnrolledBeanAsArraySerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnrolledBeanAsArraySerializer.java index 88741abb81..b064d5f55a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnrolledBeanAsArraySerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnrolledBeanAsArraySerializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; import java.util.Set; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.WritableTypeId; @@ -156,7 +156,7 @@ public void resolve(SerializerProvider provider) throws JsonMappingException @Override public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { WritableTypeId typeIdDef = _typeIdDef(typeSer, bean, JsonToken.START_ARRAY); typeSer.writeTypePrefix(gen, ctxt, typeIdDef); @@ -172,7 +172,7 @@ public void serializeWithType(Object bean, JsonGenerator gen, */ @Override public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { if (provider.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED) && hasSingleElement(provider)) { @@ -201,7 +201,7 @@ private boolean hasSingleElement(SerializerProvider provider) { protected final void serializeNonFiltered(Object bean, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { BeanPropertyWriter prop = null; try { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnsupportedTypeSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnsupportedTypeSerializer.java index cea4c3d459..33527325f5 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnsupportedTypeSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnsupportedTypeSerializer.java @@ -1,7 +1,5 @@ package com.fasterxml.jackson.databind.ser.impl; -import java.io.IOException; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JavaType; @@ -29,7 +27,7 @@ public UnsupportedTypeSerializer(JavaType t, String msg) { } @Override - public void serialize(Object value, JsonGenerator g, SerializerProvider ctxt) throws IOException { + public void serialize(Object value, JsonGenerator g, SerializerProvider ctxt) throws JacksonException { ctxt.reportBadDefinition(_type, _message); } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnwrappingBeanSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnwrappingBeanSerializer.java index b40fc6ba00..7dfe197b96 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnwrappingBeanSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/impl/UnwrappingBeanSerializer.java @@ -1,5 +1,8 @@ package com.fasterxml.jackson.databind.ser.impl; +import java.util.Set; + +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -8,9 +11,6 @@ import com.fasterxml.jackson.databind.ser.std.BeanSerializerBase; import com.fasterxml.jackson.databind.util.NameTransformer; -import java.io.IOException; -import java.util.Set; - public class UnwrappingBeanSerializer extends BeanSerializerBase { @@ -122,7 +122,7 @@ protected BeanSerializerBase asArraySerializer() { * {@link BeanPropertyWriter} instances. */ @Override - public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) throws IOException + public final void serialize(Object bean, JsonGenerator gen, SerializerProvider provider) throws JacksonException { if (_objectIdWriter != null) { _serializeWithObjectId(bean, gen, provider, false); @@ -145,7 +145,7 @@ public final void serialize(Object bean, JsonGenerator gen, SerializerProvider p @Override public void serializeWithType(Object bean, JsonGenerator gen, SerializerProvider provider, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) throws JacksonException { if (provider.isEnabled(SerializationFeature.FAIL_ON_UNWRAPPED_TYPE_IDENTIFIERS)) { provider.reportBadDefinition(handledType(), diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java index 7ca4bcbc36..64787326f0 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/BooleanSerializer.java @@ -1,11 +1,11 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - import com.fasterxml.jackson.annotation.JsonFormat; + import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser.NumberType; + import com.fasterxml.jackson.databind.BeanProperty; import com.fasterxml.jackson.databind.JavaType; import com.fasterxml.jackson.databind.JsonMappingException; @@ -88,15 +88,32 @@ public AsNumber(boolean forPrimitive) { _forPrimitive = forPrimitive; } + @Override + public JsonSerializer createContextual(SerializerProvider serializers, + BeanProperty property) + { + JsonFormat.Value format = findFormatOverrides(serializers, + property, Boolean.class); + if (format != null) { + JsonFormat.Shape shape = format.getShape(); + if (!shape.isNumeric()) { + return new BooleanSerializer(_forPrimitive); + } + } + return this; + } + @Override public void serialize(Object value, JsonGenerator g, SerializerProvider provider) - throws JacksonException { + throws JacksonException + { g.writeNumber((Boolean.FALSE.equals(value)) ? 0 : 1); } @Override public final void serializeWithType(Object value, JsonGenerator g, SerializerProvider provider, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) + throws JacksonException { // 27-Mar-2017, tatu: Actually here we CAN NOT serialize as number without type, // since with natural types that would map to number, not boolean. So choice @@ -106,25 +123,10 @@ public final void serializeWithType(Object value, JsonGenerator g, SerializerPro } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { // 27-Mar-2017, tatu: As usual, bit tricky but... seems like we should call // visitor for actual representation visitIntFormat(visitor, typeHint, NumberType.INT); } - - @Override - public JsonSerializer createContextual(SerializerProvider serializers, - BeanProperty property) throws JsonMappingException - { - JsonFormat.Value format = findFormatOverrides(serializers, - property, Boolean.class); - if (format != null) { - JsonFormat.Shape shape = format.getShape(); - if (!shape.isNumeric()) { - return new BooleanSerializer(_forPrimitive); - } - } - return this; - } } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/CalendarSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/CalendarSerializer.java index 12520d62e4..ff86285d2e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/CalendarSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/CalendarSerializer.java @@ -1,10 +1,10 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.text.DateFormat; import java.util.Calendar; import com.fasterxml.jackson.core.*; + import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; @@ -36,7 +36,8 @@ protected long _timestamp(Calendar value) { } @Override - public void serialize(Calendar value, JsonGenerator g, SerializerProvider provider) throws IOException + public void serialize(Calendar value, JsonGenerator g, SerializerProvider provider) + throws JacksonException { if (_asTimestamp(provider)) { g.writeNumber(_timestamp(value)); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/DateSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/DateSerializer.java index e324520fa6..39b7cfa24c 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/DateSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/DateSerializer.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.text.DateFormat; import java.util.*; @@ -41,7 +40,8 @@ protected long _timestamp(Date value) { } @Override - public void serialize(Date value, JsonGenerator g, SerializerProvider provider) throws IOException + public void serialize(Date value, JsonGenerator g, SerializerProvider provider) + throws JacksonException { if (_asTimestamp(provider)) { g.writeNumber(_timestamp(value)); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java index dcfe040381..4ab064238f 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/DateTimeSerializerBase.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.Date; @@ -9,7 +8,7 @@ import java.util.concurrent.atomic.AtomicReference; import com.fasterxml.jackson.annotation.JsonFormat; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonParser; @@ -158,7 +157,7 @@ public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType t @Override public abstract void serialize(T value, JsonGenerator gen, SerializerProvider serializers) - throws IOException; + throws JacksonException; /* /********************************************************** @@ -192,10 +191,8 @@ protected void _acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaTy } } - /** - * @since 2.9 - */ - protected void _serializeAsString(Date value, JsonGenerator g, SerializerProvider provider) throws IOException + protected void _serializeAsString(Date value, JsonGenerator g, SerializerProvider provider) + throws JacksonException { if (_customFormat == null) { provider.defaultSerializeDateValue(value, g); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java index 20fc5b18a6..4f9e4898ac 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/EnumSerializer.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.util.LinkedHashSet; import java.util.Set; import java.util.Objects; @@ -105,7 +104,7 @@ public JsonSerializer createContextual(SerializerProvider ctxt, @Override public final void serialize(Enum en, JsonGenerator g, SerializerProvider ctxt) - throws IOException + throws JacksonException { // Serialize as index? if (_serializeAsIndex(ctxt)) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/InetSocketAddressSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/InetSocketAddressSerializer.java index 11eab95852..f3c4cf4bec 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/InetSocketAddressSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/InetSocketAddressSerializer.java @@ -1,11 +1,12 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.net.*; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.WritableTypeId; + import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -18,7 +19,8 @@ public class InetSocketAddressSerializer public InetSocketAddressSerializer() { super(InetSocketAddress.class); } @Override - public void serialize(InetSocketAddress value, JsonGenerator jgen, SerializerProvider provider) throws IOException + public void serialize(InetSocketAddress value, JsonGenerator jgen, SerializerProvider provider) + throws JacksonException { InetAddress addr = value.getAddress(); String str = addr == null ? value.getHostName() : addr.toString().trim(); @@ -39,7 +41,8 @@ public void serialize(InetSocketAddress value, JsonGenerator jgen, SerializerPro @Override public void serializeWithType(InetSocketAddress value, JsonGenerator g, - SerializerProvider ctxt, TypeSerializer typeSer) throws IOException + SerializerProvider ctxt, TypeSerializer typeSer) + throws JacksonException { // Better ensure we don't use specific sub-classes... WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, ctxt, diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java index 7bb7bcc20f..865b3293d1 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/IterableSerializer.java @@ -1,9 +1,9 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.util.*; import com.fasterxml.jackson.core.*; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -65,7 +65,7 @@ public boolean hasSingleElement(Iterable value) { @Override public final void serialize(Iterable value, JsonGenerator g, - SerializerProvider ctxt) throws IOException + SerializerProvider ctxt) throws JacksonException { if (((_unwrapSingle == null) && ctxt.isEnabled(SerializationFeature.WRITE_SINGLE_ELEM_ARRAYS_UNWRAPPED)) @@ -82,7 +82,7 @@ public final void serialize(Iterable value, JsonGenerator g, @Override public void serializeContents(Iterable value, JsonGenerator g, - SerializerProvider ctxt) throws IOException + SerializerProvider ctxt) throws JacksonException { Iterator it = value.iterator(); if (it.hasNext()) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java index 0e84507f0d..b99662bb9c 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/RawSerializer.java @@ -1,9 +1,8 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.type.WritableTypeId; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -25,14 +24,14 @@ public RawSerializer(Class cls) { } @Override - public void serialize(T value, JsonGenerator g, SerializerProvider ctxt) throws IOException { + public void serialize(T value, JsonGenerator g, SerializerProvider ctxt) throws JacksonException { g.writeRawValue(value.toString()); } @Override public void serializeWithType(T value, JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, ctxt, typeSer.typeId(value, JsonToken.VALUE_EMBEDDED_OBJECT)); @@ -41,7 +40,7 @@ public void serializeWithType(T value, JsonGenerator g, SerializerProvider ctxt, } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { // type not really known, but since it is a JSON string: visitStringFormat(visitor, typeHint); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java index 4106e611f9..fff5a7cec7 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ReferenceTypeSerializer.java @@ -1,9 +1,7 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - import com.fasterxml.jackson.annotation.JsonInclude; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -277,7 +275,7 @@ protected boolean _useStatic(SerializerProvider serializers, BeanProperty proper */ @Override - public boolean isEmpty(SerializerProvider provider, T value) throws IOException + public boolean isEmpty(SerializerProvider provider, T value) throws JacksonException { // First, absent value (note: null check is just sanity check here) if (!_isValuePresent(value)) { @@ -317,7 +315,7 @@ public JavaType getReferredType() { @Override public void serialize(T ref, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { Object value = _getReferencedIfPresent(ref); if (value == null) { @@ -338,9 +336,9 @@ public void serialize(T ref, JsonGenerator g, SerializerProvider provider) } @Override - public void serializeWithType(T ref, - JsonGenerator g, SerializerProvider provider, - TypeSerializer typeSer) throws IOException + public void serializeWithType(T ref, JsonGenerator g, SerializerProvider provider, + TypeSerializer typeSer) + throws JacksonException { Object value = _getReferencedIfPresent(ref); if (value == null) { diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java index 76af733a2c..8689117038 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/SerializableSerializer.java @@ -1,10 +1,8 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - import com.fasterxml.jackson.core.*; + import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.JsonSerializable; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; @@ -34,19 +32,21 @@ public boolean isEmpty(SerializerProvider serializers, JsonSerializable value) { } @Override - public void serialize(JsonSerializable value, JsonGenerator gen, SerializerProvider serializers) throws IOException { + public void serialize(JsonSerializable value, JsonGenerator gen, SerializerProvider serializers) + throws JacksonException + { value.serialize(gen, serializers); } @Override public final void serializeWithType(JsonSerializable value, JsonGenerator gen, SerializerProvider serializers, - TypeSerializer typeSer) throws IOException { + TypeSerializer typeSer) throws JacksonException + { value.serializeWithType(gen, serializers, typeSer); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) - throws JsonMappingException { visitor.expectAnyFormat(typeHint); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlDateSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlDateSerializer.java index dee8b92fc0..831b24676b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlDateSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlDateSerializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.text.DateFormat; +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -38,7 +38,7 @@ protected long _timestamp(java.sql.Date value) { @Override public void serialize(java.sql.Date value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { if (_asTimestamp(provider)) { g.writeNumber(_timestamp(value)); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java index 37316d6ca8..13e4cd6342 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/SqlTimeSerializer.java @@ -1,8 +1,8 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; + import com.fasterxml.jackson.databind.*; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; @@ -15,14 +15,14 @@ public class SqlTimeSerializer public SqlTimeSerializer() { super(java.sql.Time.class); } @Override - public void serialize(java.sql.Time value, JsonGenerator g, SerializerProvider provider) throws IOException + public void serialize(java.sql.Time value, JsonGenerator g, SerializerProvider provider) + throws JacksonException { g.writeString(value.toString()); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) - throws JsonMappingException { visitStringFormat(visitor, typeHint, JsonValueFormat.DATE_TIME); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java index ce7bd3e184..58bd173f9e 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StaticListSerializerBase.java @@ -1,11 +1,10 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.util.*; import java.util.Objects; import com.fasterxml.jackson.annotation.JsonFormat; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -114,5 +113,5 @@ protected abstract void acceptContentVisitor(JsonArrayFormatVisitor visitor) // just to make sure it gets implemented: @Override public abstract void serializeWithType(T value, JsonGenerator g, - SerializerProvider provider, TypeSerializer typeSer) throws IOException; + SerializerProvider provider, TypeSerializer typeSer) throws JacksonException; } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java index 8273035339..3a3cae114d 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdArraySerializers.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.util.HashMap; import com.fasterxml.jackson.core.*; @@ -132,7 +131,7 @@ public boolean hasSingleElement(boolean[] value) { } @Override - public final void serialize(boolean[] value, JsonGenerator g, SerializerProvider provider) throws IOException + public final void serialize(boolean[] value, JsonGenerator g, SerializerProvider provider) throws JacksonException { final int len = value.length; if ((len == 1) && _shouldUnwrapSingle(provider)) { @@ -146,7 +145,7 @@ public final void serialize(boolean[] value, JsonGenerator g, SerializerProvider @Override public void serializeContents(boolean[] value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { g.writeBoolean(value[i]); @@ -201,7 +200,7 @@ public boolean hasSingleElement(short[] value) { } @Override - public final void serialize(short[] value, JsonGenerator g, SerializerProvider provider) throws IOException + public final void serialize(short[] value, JsonGenerator g, SerializerProvider provider) throws JacksonException { final int len = value.length; if ((len == 1) && _shouldUnwrapSingle(provider)) { @@ -215,7 +214,7 @@ public final void serialize(short[] value, JsonGenerator g, SerializerProvider p @Override public void serializeContents(short[] value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { g.writeNumber((int)value[i]); @@ -249,7 +248,7 @@ public boolean isEmpty(SerializerProvider prov, char[] value) { @Override public void serialize(char[] value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { // [JACKSON-289] allows serializing as 'sparse' char array too: if (provider.isEnabled(SerializationFeature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS)) { @@ -264,7 +263,7 @@ public void serialize(char[] value, JsonGenerator g, SerializerProvider provider @Override public void serializeWithType(char[] value, JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { // [JACKSON-289] allows serializing as 'sparse' char array too: final boolean asArray = ctxt.isEnabled(SerializationFeature.WRITE_CHAR_ARRAYS_AS_JSON_ARRAYS); @@ -282,7 +281,7 @@ public void serializeWithType(char[] value, JsonGenerator g, SerializerProvider } private final void _writeArrayContents(JsonGenerator g, char[] value) - throws IOException + throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { g.writeString(value, i, 1); @@ -347,7 +346,7 @@ public boolean hasSingleElement(int[] value) { } @Override - public final void serialize(int[] value, JsonGenerator g, SerializerProvider provider) throws IOException + public final void serialize(int[] value, JsonGenerator g, SerializerProvider provider) throws JacksonException { final int len = value.length; if ((len == 1) && _shouldUnwrapSingle(provider)) { @@ -360,7 +359,7 @@ public final void serialize(int[] value, JsonGenerator g, SerializerProvider pro @Override public void serializeContents(int[] value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { g.writeNumber(value[i]); @@ -414,7 +413,7 @@ public boolean hasSingleElement(long[] value) { } @Override - public final void serialize(long[] value, JsonGenerator g, SerializerProvider provider) throws IOException + public final void serialize(long[] value, JsonGenerator g, SerializerProvider provider) throws JacksonException { final int len = value.length; if ((len == 1) && _shouldUnwrapSingle(provider)) { @@ -427,7 +426,7 @@ public final void serialize(long[] value, JsonGenerator g, SerializerProvider pr @Override public void serializeContents(long[] value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { g.writeNumber(value[i]); @@ -484,7 +483,7 @@ public boolean hasSingleElement(float[] value) { } @Override - public final void serialize(float[] value, JsonGenerator g, SerializerProvider provider) throws IOException + public final void serialize(float[] value, JsonGenerator g, SerializerProvider provider) throws JacksonException { final int len = value.length; if ((len == 1) && _shouldUnwrapSingle(provider)) { @@ -498,7 +497,7 @@ public final void serialize(float[] value, JsonGenerator g, SerializerProvider p @Override public void serializeContents(float[] value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { g.writeNumber(value[i]); @@ -565,7 +564,7 @@ public boolean hasSingleElement(double[] value) { } @Override - public final void serialize(double[] value, JsonGenerator g, SerializerProvider provider) throws IOException + public final void serialize(double[] value, JsonGenerator g, SerializerProvider provider) throws JacksonException { final int len = value.length; if ((len == 1) && _shouldUnwrapSingle(provider)) { @@ -577,7 +576,7 @@ public final void serialize(double[] value, JsonGenerator g, SerializerProvider } @Override - public void serializeContents(double[] value, JsonGenerator g, SerializerProvider provider) throws IOException + public void serializeContents(double[] value, JsonGenerator g, SerializerProvider provider) throws JacksonException { for (int i = 0, len = value.length; i < len; ++i) { g.writeNumber(value[i]); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java index 23a84b579c..010c05815b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdDelegatingSerializer.java @@ -1,7 +1,6 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -163,7 +162,8 @@ public JsonSerializer getDelegatee() { */ @Override - public void serialize(Object value, JsonGenerator gen, SerializerProvider ctxt) throws IOException + public void serialize(Object value, JsonGenerator gen, SerializerProvider ctxt) + throws JacksonException { Object delegateValue = convertValue(value); // should we accept nulls? @@ -181,11 +181,11 @@ public void serialize(Object value, JsonGenerator gen, SerializerProvider ctxt) @Override public void serializeWithType(Object value, JsonGenerator gen, SerializerProvider ctxt, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) + throws JacksonException { - /* 03-Oct-2012, tatu: This is actually unlikely to work ok... but for now, - * let's give it a chance? - */ + // 03-Oct-2012, tatu: This is actually unlikely to work ok... but for now, + // let's give it a chance? Object delegateValue = convertValue(value); JsonSerializer ser = _delegateSerializer; if (ser == null) { @@ -195,7 +195,7 @@ public void serializeWithType(Object value, JsonGenerator gen, SerializerProvide } @Override - public boolean isEmpty(SerializerProvider ctxt, Object value) throws IOException + public boolean isEmpty(SerializerProvider ctxt, Object value) { Object delegateValue = convertValue(value); if (delegateValue == null) { @@ -216,11 +216,10 @@ public boolean isEmpty(SerializerProvider ctxt, Object value) throws IOException @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) - throws JsonMappingException { - /* 03-Sep-2012, tatu: Not sure if this can be made to really work - * properly... but for now, try this: - */ + // 03-Sep-2012, tatu: Not sure if this can be made to really work + // properly... but for now, try this: + // 02-Apr-2015, tatu: For dynamic case, very little we can do if (_delegateSerializer != null) { _delegateSerializer.acceptJsonFormatVisitor(visitor, typeHint); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java index 144944a4d4..045fba5bdb 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdJdkSerializers.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.*; import java.util.*; import java.util.concurrent.atomic.*; @@ -62,12 +61,12 @@ public static class AtomicBooleanSerializer public AtomicBooleanSerializer() { super(AtomicBoolean.class, false); } @Override - public void serialize(AtomicBoolean value, JsonGenerator gen, SerializerProvider provider) throws IOException { + public void serialize(AtomicBoolean value, JsonGenerator gen, SerializerProvider provider) throws JacksonException { gen.writeBoolean(value.get()); } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { visitor.expectBooleanFormat(typeHint); } } @@ -78,12 +77,12 @@ public static class AtomicIntegerSerializer public AtomicIntegerSerializer() { super(AtomicInteger.class, false); } @Override - public void serialize(AtomicInteger value, JsonGenerator gen, SerializerProvider provider) throws IOException { + public void serialize(AtomicInteger value, JsonGenerator gen, SerializerProvider provider) throws JacksonException { gen.writeNumber(value.get()); } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { visitIntFormat(visitor, typeHint, JsonParser.NumberType.INT); } @@ -95,13 +94,12 @@ public static class AtomicLongSerializer public AtomicLongSerializer() { super(AtomicLong.class, false); } @Override - public void serialize(AtomicLong value, JsonGenerator gen, SerializerProvider provider) throws IOException { + public void serialize(AtomicLong value, JsonGenerator gen, SerializerProvider provider) throws JacksonException { gen.writeNumber(value.get()); } @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) - throws JsonMappingException { visitIntFormat(visitor, typeHint, JsonParser.NumberType.LONG); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java index 0431214d68..c1014ef747 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdKeySerializers.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.util.Calendar; import java.util.Date; @@ -135,7 +134,9 @@ public Default(int typeId, Class type) { } @Override - public void serialize(Object value, JsonGenerator g, SerializerProvider provider) throws IOException { + public void serialize(Object value, JsonGenerator g, SerializerProvider provider) + throws JacksonException + { switch (_typeId) { case TYPE_DATE: provider.defaultSerializeDateKey((Date)value, g); @@ -203,7 +204,7 @@ Object readResolve() { @Override public void serialize(Object value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { Class cls = value.getClass(); PropertySerializerMap m = _dynamicSerializers; @@ -248,7 +249,9 @@ public static class StringKeySerializer extends StdSerializer public StringKeySerializer() { super(String.class); } @Override - public void serialize(Object value, JsonGenerator g, SerializerProvider provider) throws IOException { + public void serialize(Object value, JsonGenerator g, SerializerProvider provider) + throws JacksonException + { g.writeFieldName((String) value); } } @@ -273,7 +276,7 @@ public static EnumKeySerializer construct(Class enumType, @Override public void serialize(Object value, JsonGenerator g, SerializerProvider serializers) - throws IOException + throws JacksonException { if (serializers.isEnabled(SerializationFeature.WRITE_ENUMS_USING_TO_STRING)) { g.writeFieldName(value.toString()); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java index 716a931bed..fa30fdd06d 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StdScalarSerializer.java @@ -1,11 +1,9 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.type.WritableTypeId; + import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -46,7 +44,8 @@ protected StdScalarSerializer(StdScalarSerializer src) { */ @Override public void serializeWithType(T value, JsonGenerator g, SerializerProvider ctxt, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) + throws JacksonException { // NOTE: need not really be string; just indicates "scalar of some kind" WritableTypeId typeIdDef = typeSer.writeTypePrefix(g,ctxt, @@ -57,7 +56,6 @@ public void serializeWithType(T value, JsonGenerator g, SerializerProvider ctxt, @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) - throws JsonMappingException { // 13-Sep-2013, tatu: Let's assume it's usually a String, right? visitStringFormat(visitor, typeHint); diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringLikeSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringLikeSerializer.java index 4e7d133ef2..f8bcfe93aa 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringLikeSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringLikeSerializer.java @@ -1,7 +1,6 @@ package com.fasterxml.jackson.databind.ser.std; import java.io.File; -import java.io.IOException; import java.net.URI; import java.net.URL; import java.nio.file.Path; @@ -73,7 +72,7 @@ public boolean isEmpty(SerializerProvider prov, Object value) { @Override public void serialize(Object value, JsonGenerator g, SerializerProvider provider) - throws IOException + throws JacksonException { String str; @@ -114,7 +113,7 @@ public void serialize(Object value, JsonGenerator g, SerializerProvider provider @Override public void serializeWithType(Object value, JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { // 15-Feb-2018, tatu: Note! In some cases `handledType` is base type, and not necessarily // actual specific value type (f.ex. nio.Path) @@ -125,7 +124,7 @@ public void serializeWithType(Object value, JsonGenerator g, SerializerProvider } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { visitStringFormat(visitor, typeHint); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java index 1aa57b9f89..4302b7ce8b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/StringSerializer.java @@ -1,11 +1,8 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; @@ -32,20 +29,23 @@ public boolean isEmpty(SerializerProvider prov, Object value) { } @Override - public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) throws IOException { + public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) + throws JacksonException + { gen.writeString((String) value); } @Override public final void serializeWithType(Object value, JsonGenerator gen, SerializerProvider provider, - TypeSerializer typeSer) throws IOException + TypeSerializer typeSer) + throws JacksonException { // no type info, just regular serialization gen.writeString((String) value); } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException { + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { visitStringFormat(visitor, typeHint); } } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/TimeZoneSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/TimeZoneSerializer.java index cfd14c4534..7820d8bd19 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/TimeZoneSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/TimeZoneSerializer.java @@ -1,6 +1,5 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.util.TimeZone; import com.fasterxml.jackson.core.*; @@ -13,13 +12,16 @@ public class TimeZoneSerializer extends StdScalarSerializer public TimeZoneSerializer() { super(TimeZone.class); } @Override - public void serialize(TimeZone value, JsonGenerator g, SerializerProvider provider) throws IOException { + public void serialize(TimeZone value, JsonGenerator g, SerializerProvider provider) + throws JacksonException + { g.writeString(value.getID()); } @Override - public void serializeWithType(TimeZone value, JsonGenerator g, - SerializerProvider ctxt, TypeSerializer typeSer) throws IOException + public void serializeWithType(TimeZone value, JsonGenerator g, SerializerProvider ctxt, + TypeSerializer typeSer) + throws JacksonException { // Better ensure we don't use specific sub-classes: WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, ctxt, diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java index 8900b27630..0277d26b7a 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/ToStringSerializerBase.java @@ -1,12 +1,11 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.type.WritableTypeId; + import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; import com.fasterxml.jackson.databind.jsontype.TypeSerializer; @@ -31,7 +30,7 @@ public boolean isEmpty(SerializerProvider prov, Object value) { @Override public void serialize(Object value, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { gen.writeString(valueToString(value)); } @@ -46,7 +45,7 @@ public void serialize(Object value, JsonGenerator gen, SerializerProvider provid @Override public void serializeWithType(Object value, JsonGenerator g, SerializerProvider ctxt, TypeSerializer typeSer) - throws IOException + throws JacksonException { WritableTypeId typeIdDef = typeSer.writeTypePrefix(g, ctxt, typeSer.typeId(value, JsonToken.VALUE_STRING)); @@ -55,7 +54,7 @@ public void serializeWithType(Object value, JsonGenerator g, SerializerProvider } @Override - public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) throws JsonMappingException + public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) { visitStringFormat(visitor, typeHint); } diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java index 6ef1a15c79..3c6654a16b 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/TokenBufferSerializer.java @@ -1,11 +1,9 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; - import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.type.WritableTypeId; + import com.fasterxml.jackson.databind.JavaType; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.SerializerProvider; import com.fasterxml.jackson.databind.annotation.JacksonStdImpl; import com.fasterxml.jackson.databind.jsonFormatVisitors.JsonFormatVisitorWrapper; @@ -26,7 +24,7 @@ public class TokenBufferSerializer @Override public void serialize(TokenBuffer value, JsonGenerator jgen, SerializerProvider provider) - throws IOException + throws JacksonException { value.serialize(jgen); } @@ -42,8 +40,9 @@ public void serialize(TokenBuffer value, JsonGenerator jgen, SerializerProvider * than doing introspection on both serialization and deserialization. */ @Override - public final void serializeWithType(TokenBuffer value, JsonGenerator g, - SerializerProvider ctxt, TypeSerializer typeSer) throws IOException + public final void serializeWithType(TokenBuffer value, JsonGenerator g, SerializerProvider ctxt, + TypeSerializer typeSer) + throws JacksonException { // 28-Jun-2017, tatu: As per javadoc, not sure what to report as likely shape. Could // even look into first actual token inside... but, for now let's keep it simple @@ -55,7 +54,6 @@ public final void serializeWithType(TokenBuffer value, JsonGenerator g, @Override public void acceptJsonFormatVisitor(JsonFormatVisitorWrapper visitor, JavaType typeHint) - throws JsonMappingException { // Not 100% sure what we should say here: type is basically not known. // This seems like closest approximation diff --git a/src/main/java/com/fasterxml/jackson/databind/ser/std/UUIDSerializer.java b/src/main/java/com/fasterxml/jackson/databind/ser/std/UUIDSerializer.java index 26389d87b6..74b8993db7 100644 --- a/src/main/java/com/fasterxml/jackson/databind/ser/std/UUIDSerializer.java +++ b/src/main/java/com/fasterxml/jackson/databind/ser/std/UUIDSerializer.java @@ -1,11 +1,10 @@ package com.fasterxml.jackson.databind.ser.std; -import java.io.IOException; import java.util.Objects; import java.util.UUID; import com.fasterxml.jackson.annotation.JsonFormat; - +import com.fasterxml.jackson.core.JacksonException; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.*; @@ -29,16 +28,11 @@ public class UUIDSerializer * Configuration setting that indicates if serialization as binary * (native or Base64-encoded) has been forced; {@code null} means * "use default heuristic" - * - * @since 2.11.3 */ protected final Boolean _asBinary; public UUIDSerializer() { this(null); } - /** - * @since 2.11.3 - */ protected UUIDSerializer(Boolean asBinary) { super(UUID.class); _asBinary = asBinary; @@ -57,7 +51,7 @@ public boolean isEmpty(SerializerProvider prov, UUID value) @Override public JsonSerializer createContextual(SerializerProvider serializers, - BeanProperty property) throws JsonMappingException + BeanProperty property) { JsonFormat.Value format = findFormatOverrides(serializers, property, handledType()); @@ -80,7 +74,7 @@ public JsonSerializer createContextual(SerializerProvider serializers, @Override public void serialize(UUID value, JsonGenerator gen, SerializerProvider provider) - throws IOException + throws JacksonException { // First: perhaps we could serialize it as raw binary data? if (_writeAsBinary(gen)) { @@ -110,7 +104,6 @@ public void serialize(UUID value, JsonGenerator gen, SerializerProvider provider gen.writeString(ch, 0, 36); } - // @since 2.11.3 protected boolean _writeAsBinary(JsonGenerator g) { if (_asBinary != null) {