Skip to content

Commit

Permalink
Merge branch '2.12'
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Jun 13, 2020
2 parents 19f4b19 + 7678ce4 commit 672ad85
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 106 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public Boolean deserialize(JsonParser p, DeserializationContext ctxt) throws IOE
return Boolean.FALSE;
}
if (_primitive) {
return _parseBooleanPrimitive(ctxt, p, _valueClass);
return _parseBooleanPrimitive(ctxt, p);
}
return _parseBoolean(ctxt, p, _valueClass);
}
Expand All @@ -229,7 +229,7 @@ public Boolean deserializeWithType(JsonParser p, DeserializationContext ctxt,
return Boolean.FALSE;
}
if (_primitive) {
return _parseBooleanPrimitive(ctxt, p, _valueClass);
return _parseBooleanPrimitive(ctxt, p);
}
return _parseBoolean(ctxt, p, _valueClass);
}
Expand All @@ -253,9 +253,9 @@ public Byte deserialize(JsonParser p, DeserializationContext ctxt) throws IOExce
if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) {
return p.getByteValue();
}
// if (_primitive) {
// return _parseBytePrimitive(ctxt, p, _valueClass);
// }
if (_primitive) {
return _parseBytePrimitive(ctxt, p);
}
return _parseByte(ctxt, p, _valueClass);
}
}
Expand All @@ -279,9 +279,9 @@ public Short deserialize(JsonParser p, DeserializationContext ctxt)
if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) {
return p.getShortValue();
}
// if (_primitive) {
// return _parseShortPrimitive(ctxt, p, _valueClass);
// }
if (_primitive) {
return _parseShortPrimitive(ctxt, p);
}
return _parseShort(ctxt, p, _valueClass);
}
}
Expand Down Expand Up @@ -365,7 +365,10 @@ public Integer deserialize(JsonParser p, DeserializationContext ctxt) throws IOE
if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) {
return p.getIntValue();
}
return _parseInteger(p, ctxt);
if (_primitive) {
return _parseIntPrimitive(ctxt, p);
}
return _parseInteger(ctxt, p, _valueClass);
}

// Since we can never have type info ("natural type"; String, Boolean, Integer, Double):
Expand All @@ -377,56 +380,10 @@ public Integer deserializeWithType(JsonParser p, DeserializationContext ctxt,
if (p.hasToken(JsonToken.VALUE_NUMBER_INT)) {
return p.getIntValue();
}
return _parseInteger(p, ctxt);
}

protected final Integer _parseInteger(JsonParser p, DeserializationContext ctxt) throws IOException
{
switch (p.currentTokenId()) {
// NOTE: caller assumed to usually check VALUE_NUMBER_INT in fast path
case JsonTokenId.ID_NUMBER_INT:
return Integer.valueOf(p.getIntValue());
case JsonTokenId.ID_NUMBER_FLOAT: // coercing may work too
if (!ctxt.isEnabled(DeserializationFeature.ACCEPT_FLOAT_AS_INT)) {
_failDoubleToIntCoercion(p, ctxt, "Integer");
}
return Integer.valueOf(p.getValueAsInt());
case JsonTokenId.ID_STRING: // let's do implicit re-parse
String text = p.getText();
CoercionAction act = _checkFromStringCoercion(ctxt, text);
if (act == CoercionAction.AsNull) {
return (Integer) getNullValue(ctxt);
}
if (act == CoercionAction.AsEmpty) {
return (Integer) getEmptyValue(ctxt);
}
text = text.trim();
if (_hasTextualNull(text)) {
return (Integer) _coerceTextualNull(ctxt, _primitive);
}
final int len = text.length();
try {
if (len > 9) {
long l = Long.parseLong(text);
if (_intOverflow(l)) {
return (Integer) ctxt.handleWeirdStringValue(_valueClass, text, String.format(
"Overflow: numeric value (%s) out of range of Integer (%d - %d)",
text, Integer.MIN_VALUE, Integer.MAX_VALUE));
}
return Integer.valueOf((int) l);
}
return Integer.valueOf(NumberInput.parseInt(text));
} catch (IllegalArgumentException iae) {
return (Integer) ctxt.handleWeirdStringValue(_valueClass, text,
"not a valid Integer value");
}
case JsonTokenId.ID_NULL:
return (Integer) _coerceNullToken(ctxt, _primitive);
case JsonTokenId.ID_START_ARRAY:
return _deserializeFromArray(p, ctxt);
if (_primitive) {
return _parseIntPrimitive(ctxt, p);
}
// Otherwise, no can do:
return (Integer) ctxt.handleUnexpectedToken(getValueType(ctxt), p);
return _parseInteger(ctxt, p, _valueClass);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public boolean[] deserialize(JsonParser p, DeserializationContext ctxt)
_verifyNullForPrimitive(ctxt);
value = false;
} else {
value = _parseBooleanPrimitive(ctxt, p, Boolean.TYPE);
value = _parseBooleanPrimitive(ctxt, p);
}
if (ix >= chunk.length) {
chunk = builder.appendCompletedChunk(chunk, ix);
Expand All @@ -395,7 +395,7 @@ public boolean[] deserialize(JsonParser p, DeserializationContext ctxt)
@Override
protected boolean[] handleSingleElementUnwrapped(JsonParser p,
DeserializationContext ctxt) throws IOException {
return new boolean[] { _parseBooleanPrimitive(ctxt, p, Boolean.TYPE) };
return new boolean[] { _parseBooleanPrimitive(ctxt, p) };
}

@Override
Expand Down Expand Up @@ -492,7 +492,7 @@ public byte[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOEx
_verifyNullForPrimitive(ctxt);
value = (byte) 0;
} else {
value = _parseBytePrimitive(ctxt, p, Byte.TYPE);
value = _parseBytePrimitive(ctxt, p);
}
}
if (ix >= chunk.length) {
Expand Down Expand Up @@ -584,7 +584,7 @@ public short[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOE
_verifyNullForPrimitive(ctxt);
value = (short) 0;
} else {
value = _parseShortPrimitive(ctxt, p, Short.TYPE);
value = _parseShortPrimitive(ctxt, p);
}
if (ix >= chunk.length) {
chunk = builder.appendCompletedChunk(chunk, ix);
Expand All @@ -601,7 +601,7 @@ public short[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOE
@Override
protected short[] handleSingleElementUnwrapped(JsonParser p,
DeserializationContext ctxt) throws IOException {
return new short[] { _parseShortPrimitive(ctxt, p, Short.TYPE) };
return new short[] { _parseShortPrimitive(ctxt, p) };
}

@Override
Expand Down Expand Up @@ -660,7 +660,7 @@ public int[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOExc
_verifyNullForPrimitive(ctxt);
value = 0;
} else {
value = _parseIntPrimitive(p, ctxt);
value = _parseIntPrimitive(ctxt, p);
}
if (ix >= chunk.length) {
chunk = builder.appendCompletedChunk(chunk, ix);
Expand All @@ -677,7 +677,7 @@ public int[] deserialize(JsonParser p, DeserializationContext ctxt) throws IOExc
@Override
protected int[] handleSingleElementUnwrapped(JsonParser p,
DeserializationContext ctxt) throws IOException {
return new int[] { _parseIntPrimitive(p, ctxt) };
return new int[] { _parseIntPrimitive(ctxt, p) };
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public StackTraceElement deserialize(JsonParser p, DeserializationContext ctxt)
if (t.isNumeric()) {
lineNumber = p.getIntValue();
} else {
lineNumber = _parseIntPrimitive(p, ctxt);
lineNumber = _parseIntPrimitive(ctxt, p);
}
break;
case "methodName":
Expand Down
Loading

0 comments on commit 672ad85

Please sign in to comment.