@@ -407,11 +407,11 @@ public void resolve(DeserializationContext ctxt)
407
407
{
408
408
ExternalTypeHandler .Builder extTypes = null ;
409
409
// if ValueInstantiator can use "creator" approach, need to resolve it here...
410
+ SettableBeanProperty [] creatorProps ;
410
411
if (_valueInstantiator .canCreateFromObjectWith ()) {
411
- SettableBeanProperty [] creatorProps = _valueInstantiator .getFromObjectArguments (ctxt .getConfig ());
412
- _propertyBasedCreator = PropertyBasedCreator .construct (ctxt , _valueInstantiator , creatorProps );
412
+ creatorProps = _valueInstantiator .getFromObjectArguments (ctxt .getConfig ());
413
413
// also: need to try to resolve 'external' type ids...
414
- for (SettableBeanProperty prop : _propertyBasedCreator . properties () ) {
414
+ for (SettableBeanProperty prop : creatorProps ) {
415
415
if (prop .hasValueTypeDeserializer ()) {
416
416
TypeDeserializer typeDeser = prop .getValueTypeDeserializer ();
417
417
if (typeDeser .getTypeInclusion () == JsonTypeInfo .As .EXTERNAL_PROPERTY ) {
@@ -422,12 +422,15 @@ public void resolve(DeserializationContext ctxt)
422
422
}
423
423
}
424
424
}
425
+ } else {
426
+ creatorProps = null ;
425
427
}
426
428
427
429
UnwrappedPropertyHandler unwrapped = null ;
428
430
429
431
for (SettableBeanProperty origProp : _beanProperties ) {
430
432
SettableBeanProperty prop = origProp ;
433
+
431
434
// May already have deserializer from annotations, if so, skip:
432
435
if (!prop .hasValueDeserializer ()) {
433
436
// [Issue#125]: allow use of converters
@@ -447,6 +450,7 @@ public void resolve(DeserializationContext ctxt)
447
450
prop = prop .withValueDeserializer (cd );
448
451
}
449
452
}
453
+
450
454
// [JACKSON-235]: need to link managed references with matching back references
451
455
prop = _resolveManagedReferenceProperty (ctxt , prop );
452
456
@@ -472,11 +476,29 @@ public void resolve(DeserializationContext ctxt)
472
476
prop = _resolveInnerClassValuedProperty (ctxt , prop );
473
477
if (prop != origProp ) {
474
478
_beanProperties .replace (prop );
479
+ // [databind#795]: Make sure PropertyBasedCreator's properties stay in sync
480
+ if (creatorProps != null ) {
481
+ // 18-May-2015, tatu: _Should_ start with consistent set. But can we really
482
+ // fully count on this? May need to revisit in future; seems to hold for now.
483
+ for (int i = 0 , len = creatorProps .length ; i < len ; ++i ) {
484
+ if (creatorProps [i ] == origProp ) {
485
+ creatorProps [i ] = prop ;
486
+ break ;
487
+ }
488
+ // ... as per above, it is possible we'd need to add this as fallback
489
+ // if (but only if) identity check fails?
490
+ /*
491
+ if (creatorProps[i].getName().equals(prop.getName())) {
492
+ creatorProps[i] = prop;
493
+ break;
494
+ }
495
+ */
496
+ }
497
+ }
475
498
}
476
499
477
- /* one more thing: if this property uses "external property" type inclusion
478
- * (see [JACKSON-453]), it needs different handling altogether
479
- */
500
+ // one more thing: if this property uses "external property" type inclusion
501
+ // (see [JACKSON-453]), it needs different handling altogether
480
502
if (prop .hasValueTypeDeserializer ()) {
481
503
TypeDeserializer typeDeser = prop .getValueTypeDeserializer ();
482
504
if (typeDeser .getTypeInclusion () == JsonTypeInfo .As .EXTERNAL_PROPERTY ) {
@@ -522,7 +544,12 @@ public void resolve(DeserializationContext ctxt)
522
544
}
523
545
_delegateDeserializer = dd ;
524
546
}
525
-
547
+
548
+ // And now that we know CreatorProperty instances are also resolved can finally create the creator:
549
+ if (creatorProps != null ) {
550
+ _propertyBasedCreator = PropertyBasedCreator .construct (ctxt , _valueInstantiator , creatorProps );
551
+ }
552
+
526
553
if (extTypes != null ) {
527
554
_externalTypeIdHandler = extTypes .build ();
528
555
// we consider this non-standard, to offline handling
0 commit comments