@@ -377,10 +377,6 @@ protected final boolean _parseBooleanPrimitive(DeserializationContext ctxt,
377
377
/**
378
378
* @param ctxt Deserialization context for accessing configuration
379
379
* @param p Underlying parser
380
- * @param targetType Actual type that is being deserialized, typically
381
- * same as {@link #handledType}, and not necessarily {@code boolean}
382
- * (may be {@code boolean[]} or {@code AtomicBoolean} for example);
383
- * used for coercion config access
384
380
*/
385
381
protected final boolean _parseBooleanPrimitive (JsonParser p , DeserializationContext ctxt )
386
382
throws IOException
@@ -1284,10 +1280,12 @@ protected CoercionAction _checkFromStringCoercion(DeserializationContext ctxt, S
1284
1280
if (value .length () == 0 ) {
1285
1281
act = ctxt .findCoercionAction (logicalType , rawTargetType ,
1286
1282
CoercionInputShape .EmptyString );
1287
- return _checkCoercionActionFail (ctxt , act , "empty String (\" \" )" );
1283
+ return _checkCoercionFail (ctxt , act , rawTargetType , value ,
1284
+ "empty String (\" \" )" );
1288
1285
} else if (_isBlank (value )) {
1289
1286
act = ctxt .findCoercionFromBlankString (logicalType , rawTargetType , CoercionAction .Fail );
1290
- return _checkCoercionActionFail (ctxt , act , "blank String (all whitespace)" );
1287
+ return _checkCoercionFail (ctxt , act , rawTargetType , value ,
1288
+ "blank String (all whitespace)" );
1291
1289
} else {
1292
1290
act = ctxt .findCoercionAction (logicalType , rawTargetType , CoercionInputShape .String );
1293
1291
if (act == CoercionAction .Fail ) {
@@ -1310,7 +1308,8 @@ protected CoercionAction _checkFloatToIntCoercion(JsonParser p, DeserializationC
1310
1308
final CoercionAction act = ctxt .findCoercionAction (LogicalType .Integer ,
1311
1309
rawTargetType , CoercionInputShape .Float );
1312
1310
if (act == CoercionAction .Fail ) {
1313
- _checkCoercionActionFail (ctxt , act , "Floating-point value (" +p .getText ()+")" );
1311
+ return _checkCoercionFail (ctxt , act , rawTargetType , p .getNumberValue (),
1312
+ "Floating-point value (" +p .getText ()+")" );
1314
1313
}
1315
1314
return act ;
1316
1315
}
@@ -1325,8 +1324,9 @@ protected Boolean _coerceBooleanFromInt(JsonParser p, DeserializationContext ctx
1325
1324
CoercionAction act = ctxt .findCoercionAction (LogicalType .Boolean , rawTargetType , CoercionInputShape .Integer );
1326
1325
switch (act ) {
1327
1326
case Fail :
1328
- _checkCoercionActionFail (ctxt , act , "Integer value (" +p .getText ()+")" );
1329
- break ;
1327
+ _checkCoercionFail (ctxt , act , rawTargetType , p .getNumberValue (),
1328
+ "Integer value (" +p .getText ()+")" );
1329
+ return Boolean .FALSE ;
1330
1330
case AsNull :
1331
1331
return null ;
1332
1332
case AsEmpty :
@@ -1343,11 +1343,16 @@ protected Boolean _coerceBooleanFromInt(JsonParser p, DeserializationContext ctx
1343
1343
return !"0" .equals (p .getText ());
1344
1344
}
1345
1345
1346
- protected CoercionAction _checkCoercionActionFail (DeserializationContext ctxt ,
1347
- CoercionAction act , String inputDesc ) throws IOException
1346
+ /**
1347
+ * @since 2.12
1348
+ */
1349
+ protected CoercionAction _checkCoercionFail (DeserializationContext ctxt ,
1350
+ CoercionAction act , Class <?> targetType , Object inputValue ,
1351
+ String inputDesc )
1352
+ throws IOException
1348
1353
{
1349
1354
if (act == CoercionAction .Fail ) {
1350
- ctxt .reportInputMismatch (this ,
1355
+ ctxt .reportBadCoercion (this , targetType , inputValue ,
1351
1356
"Cannot coerce %s to %s (but could if coercion was enabled using `CoercionConfig`)" ,
1352
1357
inputDesc , _coercedTypeDesc ());
1353
1358
}
0 commit comments