Skip to content

Commit

Permalink
More #2177 work, now under 100 errors
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jan 16, 2021
1 parent 99d2cf2 commit 1620045
Show file tree
Hide file tree
Showing 51 changed files with 272 additions and 306 deletions.
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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()) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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): "
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -66,22 +67,22 @@ 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");
}

@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:
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -40,15 +40,15 @@ 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);
}

// Copied from `com.fasterxml.jackson.databind.ser.std.ByteArraySerializer`
@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,
Expand All @@ -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 {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
* <p>
Expand All @@ -22,28 +21,20 @@ public class DoubleStreamSerializer extends StdSerializer<DoubleStream>
*/
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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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
* <p>
Expand All @@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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
*
Expand Down Expand Up @@ -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())) {
Expand All @@ -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();
}
}
}
Loading

0 comments on commit 1620045

Please sign in to comment.