@@ -68,7 +68,7 @@ protected BeanDeserializer(BeanDeserializerBase src) {
68
68
protected BeanDeserializer (BeanDeserializerBase src , boolean ignoreAllUnknown ) {
69
69
super (src , ignoreAllUnknown );
70
70
}
71
-
71
+
72
72
protected BeanDeserializer (BeanDeserializerBase src , NameTransformer unwrapper ) {
73
73
super (src , unwrapper );
74
74
}
@@ -80,7 +80,7 @@ public BeanDeserializer(BeanDeserializerBase src, ObjectIdReader oir) {
80
80
public BeanDeserializer (BeanDeserializerBase src , HashSet <String > ignorableProps ) {
81
81
super (src , ignorableProps );
82
82
}
83
-
83
+
84
84
@ Override
85
85
public JsonDeserializer <Object > unwrappingDeserializer (NameTransformer unwrapper )
86
86
{
@@ -182,7 +182,7 @@ protected Object _missingToken(JsonParser p, DeserializationContext ctxt)
182
182
{
183
183
throw ctxt .endOfInputException (handledType ());
184
184
}
185
-
185
+
186
186
/**
187
187
* Secondary deserialization method, called in cases where POJO
188
188
* instance is created as part of deserialization, potentially
@@ -355,7 +355,7 @@ public Object deserializeFromObject(JsonParser p, DeserializationContext ctxt) t
355
355
* Method called to deserialize bean using "property-based creator":
356
356
* this means that a non-default constructor or factory method is
357
357
* called, and then possibly other setters. The trick is that
358
- * values for creator method need to be buffered, first; and
358
+ * values for creator method need to be buffered, first; and
359
359
* due to non-guaranteed ordering possibly some other properties
360
360
* as well.
361
361
*/
@@ -366,7 +366,7 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
366
366
{
367
367
final PropertyBasedCreator creator = _propertyBasedCreator ;
368
368
PropertyValueBuffer buffer = creator .startBuilding (p , ctxt , _objectIdReader );
369
-
369
+
370
370
// 04-Jan-2010, tatu: May need to collect unknown properties for polymorphic cases
371
371
TokenBuffer unknown = null ;
372
372
@@ -378,7 +378,7 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
378
378
SettableBeanProperty creatorProp = creator .findCreatorProperty (propName );
379
379
if (creatorProp != null ) {
380
380
// Last creator property to set?
381
- Object value = creatorProp . deserialize ( p , ctxt );
381
+ Object value = deserializeWithErrorWrapping ( creatorProp , p , ctxt , propName );
382
382
if (buffer .assignParameter (creatorProp .getCreatorIndex (), value )) {
383
383
p .nextToken (); // to move to following FIELD_NAME/END_OBJECT
384
384
Object bean ;
@@ -434,7 +434,7 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
434
434
unknown .writeFieldName (propName );
435
435
unknown .copyCurrentStructure (p );
436
436
}
437
-
437
+
438
438
// We hit END_OBJECT, so:
439
439
Object bean ;
440
440
try {
@@ -454,12 +454,24 @@ protected Object _deserializeUsingPropertyBased(final JsonParser p, final Deseri
454
454
return bean ;
455
455
}
456
456
457
+ protected Object deserializeWithErrorWrapping (SettableBeanProperty creatorProp , JsonParser p , DeserializationContext ctxt ,
458
+ String propName )
459
+ throws IOException {
460
+ try {
461
+ return creatorProp .deserialize (p , ctxt );
462
+ } catch (IOException e ) {
463
+ wrapAndThrow (e , _beanType .getRawClass (), propName , ctxt );
464
+ // exception below will be throw only if someone overwrite default implementation of wrapAndThrow method
465
+ throw e ;
466
+ }
467
+ }
468
+
457
469
/*
458
470
/**********************************************************
459
471
/* Deserializing when we have to consider an active View
460
472
/**********************************************************
461
473
*/
462
-
474
+
463
475
protected final Object deserializeWithView (JsonParser p , DeserializationContext ctxt ,
464
476
Object bean , Class <?> activeView )
465
477
throws IOException
@@ -620,7 +632,7 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
620
632
SettableBeanProperty creatorProp = creator .findCreatorProperty (propName );
621
633
if (creatorProp != null ) {
622
634
// Last creator property to set?
623
- Object value = creatorProp . deserialize ( p , ctxt );
635
+ Object value = deserializeWithErrorWrapping ( creatorProp , p , ctxt , propName );
624
636
if (buffer .assignParameter (creatorProp .getCreatorIndex (), value )) {
625
637
t = p .nextToken (); // to move to following FIELD_NAME/END_OBJECT
626
638
Object bean ;
@@ -691,7 +703,7 @@ protected Object deserializeUsingPropertyBasedWithUnwrapped(JsonParser p, Deseri
691
703
/* external type id
692
704
/**********************************************************
693
705
*/
694
-
706
+
695
707
protected Object deserializeWithExternalTypeId (JsonParser p , DeserializationContext ctxt )
696
708
throws IOException
697
709
{
@@ -700,14 +712,14 @@ protected Object deserializeWithExternalTypeId(JsonParser p, DeserializationCont
700
712
}
701
713
return deserializeWithExternalTypeId (p , ctxt , _valueInstantiator .createUsingDefault (ctxt ));
702
714
}
703
-
715
+
704
716
protected Object deserializeWithExternalTypeId (JsonParser p , DeserializationContext ctxt ,
705
717
Object bean )
706
718
throws IOException
707
719
{
708
720
final Class <?> activeView = _needViewProcesing ? ctxt .getActiveView () : null ;
709
721
final ExternalTypeHandler ext = _externalTypeIdHandler .start ();
710
-
722
+
711
723
for (JsonToken t = p .getCurrentToken (); t == JsonToken .FIELD_NAME ; t = p .nextToken ()) {
712
724
String propName = p .getCurrentName ();
713
725
t = p .nextToken ();
@@ -747,7 +759,7 @@ protected Object deserializeWithExternalTypeId(JsonParser p, DeserializationCont
747
759
continue ;
748
760
}
749
761
// Unknown: let's call handler method
750
- handleUnknownProperty (p , ctxt , bean , propName );
762
+ handleUnknownProperty (p , ctxt , bean , propName );
751
763
}
752
764
// and when we get this far, let's try finalizing the deal:
753
765
return ext .complete (p , ctxt , bean );
@@ -776,7 +788,7 @@ protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser p, D
776
788
;
777
789
} else {
778
790
// Last creator property to set?
779
- Object value = creatorProp . deserialize ( p , ctxt );
791
+ Object value = deserializeWithErrorWrapping ( creatorProp , p , ctxt , propName );
780
792
if (buffer .assignParameter (creatorProp .getCreatorIndex (), value )) {
781
793
t = p .nextToken (); // to move to following FIELD_NAME/END_OBJECT
782
794
Object bean ;
0 commit comments