Skip to content

Commit 7d6fe9a

Browse files
committed
Minor optimization: check StreamReadCapability.UNTYPED_SCALARS to allow from-string coercion for XML etc
1 parent 8676124 commit 7d6fe9a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1343,8 +1343,13 @@ protected CoercionAction _checkFromStringCoercion(DeserializationContext ctxt, S
13431343
LogicalType logicalType, Class<?> rawTargetType)
13441344
throws IOException
13451345
{
1346-
final CoercionAction act;
1346+
// 18-Dec-2020, tatu: Formats without strong typing (XML, CSV, Properties at
1347+
// least) should allow from-String "coercion" since Strings are their
1348+
// native type.
1349+
// One open question is whether Empty/Blank String are special; they might
1350+
// be so only apply short-cut to other cases, for now
13471351

1352+
final CoercionAction act;
13481353
if (value.isEmpty()) {
13491354
act = ctxt.findCoercionAction(logicalType, rawTargetType,
13501355
CoercionInputShape.EmptyString);
@@ -1355,6 +1360,10 @@ protected CoercionAction _checkFromStringCoercion(DeserializationContext ctxt, S
13551360
return _checkCoercionFail(ctxt, act, rawTargetType, value,
13561361
"blank String (all whitespace)");
13571362
} else {
1363+
// 18-Dec-2020, tatu: As per above, allow for XML, CSV, Properties
1364+
if (ctxt.isEnabled(StreamReadCapability.UNTYPED_SCALARS)) {
1365+
return CoercionAction.TryConvert;
1366+
}
13581367
act = ctxt.findCoercionAction(logicalType, rawTargetType, CoercionInputShape.String);
13591368
if (act == CoercionAction.Fail) {
13601369
// since it MIGHT (but might not), create desc here, do not use helper

0 commit comments

Comments
 (0)