Skip to content

Commit 023733e

Browse files
authored
check for fast parser flag in more places (#3523)
1 parent 4cecfc2 commit 023733e

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/main/java/com/fasterxml/jackson/databind/deser/std/StdDeserializer.java

+30-2
Original file line numberDiff line numberDiff line change
@@ -1030,7 +1030,7 @@ protected final float _parseFloatPrimitive(JsonParser p, DeserializationContext
10301030
_verifyNullForPrimitiveCoercion(ctxt, text);
10311031
return 0.0f;
10321032
}
1033-
return _parseFloatPrimitive(ctxt, text);
1033+
return _parseFloatPrimitive(p, ctxt, text);
10341034
}
10351035

10361036
/**
@@ -1047,6 +1047,20 @@ protected final float _parseFloatPrimitive(DeserializationContext ctxt, String t
10471047
return _nonNullNumber(v).floatValue();
10481048
}
10491049

1050+
/**
1051+
* @since 2.14
1052+
*/
1053+
protected final float _parseFloatPrimitive(JsonParser p, DeserializationContext ctxt, String text)
1054+
throws IOException
1055+
{
1056+
try {
1057+
return NumberInput.parseFloat(text, p.isEnabled(StreamReadFeature.USE_FAST_DOUBLE_PARSER));
1058+
} catch (IllegalArgumentException iae) { }
1059+
Number v = (Number) ctxt.handleWeirdStringValue(Float.TYPE, text,
1060+
"not a valid `float` value");
1061+
return _nonNullNumber(v).floatValue();
1062+
}
1063+
10501064
/**
10511065
* Helper method called to check whether given String value contains one of
10521066
* "special" values (currently, NaN ("not-a-number") and plus/minus Infinity)
@@ -1137,7 +1151,7 @@ protected final double _parseDoublePrimitive(JsonParser p, DeserializationContex
11371151
_verifyNullForPrimitiveCoercion(ctxt, text);
11381152
return 0.0;
11391153
}
1140-
return _parseDoublePrimitive(ctxt, text);
1154+
return _parseDoublePrimitive(p, ctxt, text);
11411155
}
11421156

11431157
/**
@@ -1154,6 +1168,20 @@ protected final double _parseDoublePrimitive(DeserializationContext ctxt, String
11541168
return _nonNullNumber(v).doubleValue();
11551169
}
11561170

1171+
/**
1172+
* @since 2.14
1173+
*/
1174+
protected final double _parseDoublePrimitive(JsonParser p, DeserializationContext ctxt, String text)
1175+
throws IOException
1176+
{
1177+
try {
1178+
return _parseDouble(text, p.isEnabled(StreamReadFeature.USE_FAST_DOUBLE_PARSER));
1179+
} catch (IllegalArgumentException iae) { }
1180+
Number v = (Number) ctxt.handleWeirdStringValue(Double.TYPE, text,
1181+
"not a valid `double` value (as String to convert)");
1182+
return _nonNullNumber(v).doubleValue();
1183+
}
1184+
11571185
/**
11581186
* Helper method for encapsulating calls to low-level double value parsing; single place
11591187
* just because we need a work-around that must be applied to all calls.

0 commit comments

Comments
 (0)