Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 12, 2020
1 parent a9f52ae commit 505716d
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,14 @@ protected final boolean _parseBooleanPrimitive(JsonParser p, DeserializationCont
return _parseBooleanPrimitive(ctxt, p, Boolean.TYPE);
}

// @since 2.12
/**
* @param ctxt Deserialization context for accessing configuration
* @param p Underlying parser
* @param targetType Actual type that is being deserialized, typically
* same as {@link #handledType}, and not necessarily {@code boolean}
* (may be {@code boolean[]} or {@code AtomicBoolean} for example);
* used for coercion config access
*/
protected final boolean _parseBooleanPrimitive(DeserializationContext ctxt,
JsonParser p, Class<?> targetType)
throws IOException
Expand All @@ -372,7 +379,7 @@ protected final boolean _parseBooleanPrimitive(DeserializationContext ctxt,

// may accept ints too, (0 == false, otherwise true)
if (t == JsonToken.VALUE_NUMBER_INT) {
Boolean b = _coerceBooleanFromInt(ctxt, p, Boolean.TYPE);
Boolean b = _coerceBooleanFromInt(ctxt, p, targetType);
// may get `null`, Boolean.TRUE or Boolean.FALSE so:
return (b == Boolean.TRUE);
}
Expand Down Expand Up @@ -425,7 +432,7 @@ protected final Boolean _parseBoolean(DeserializationContext ctxt,
}
// may accept ints too, (0 == false, otherwise true)
if (t == JsonToken.VALUE_NUMBER_INT) {
return _coerceBooleanFromInt(ctxt, p, Boolean.class);
return _coerceBooleanFromInt(ctxt, p, targetType);
}
// And finally, let's allow Strings to be converted too
if (t == JsonToken.VALUE_STRING) {
Expand Down

0 comments on commit 505716d

Please sign in to comment.