@@ -286,17 +286,19 @@ public Object complete(JsonParser p, DeserializationContext ctxt,
286
286
} else {
287
287
typeId = extProp .getDefaultTypeId ();
288
288
}
289
- } else if (_tokens [i ] == null ) {
290
- SettableBeanProperty prop = extProp .getProperty ();
291
- if (prop .isRequired () ||
292
- ctxt .isEnabled (DeserializationFeature .FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY )) {
289
+ }
290
+
291
+ if (_tokens [i ] != null ) {
292
+ values [i ] = _deserialize (p , ctxt , i , typeId );
293
+ } else {
294
+ if (ctxt .isEnabled (DeserializationFeature .FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY )) {
295
+ SettableBeanProperty prop = extProp .getProperty ();
293
296
ctxt .reportPropertyInputMismatch (_beanType , prop .getName (),
294
297
"Missing property '%s' for external type id '%s'" ,
295
298
prop .getName (), _properties [i ].getTypePropertyName ());
296
299
}
297
- }
298
- if (_tokens [i ] != null ) {
299
- values [i ] = _deserialize (p , ctxt , i , typeId );
300
+
301
+ values [i ] = _deserializeMissingToken (p , ctxt , i , typeId );
300
302
}
301
303
302
304
final SettableBeanProperty prop = extProp .getProperty ();
@@ -356,6 +358,21 @@ protected final Object _deserialize(JsonParser p, DeserializationContext ctxt,
356
358
return _properties [index ].getProperty ().deserialize (mp , ctxt );
357
359
}
358
360
361
+ @ SuppressWarnings ("resource" )
362
+ protected final Object _deserializeMissingToken (JsonParser p , DeserializationContext ctxt ,
363
+ int index , String typeId ) throws IOException
364
+ {
365
+ TokenBuffer merged = ctxt .bufferForInputBuffering (p );
366
+ merged .writeStartArray ();
367
+ merged .writeString (typeId );
368
+ merged .writeEndArray ();
369
+
370
+ // needs to point to START_OBJECT (or whatever first token is)
371
+ JsonParser mp = merged .asParser (p );
372
+ mp .nextToken ();
373
+ return _properties [index ].getProperty ().deserialize (mp , ctxt );
374
+ }
375
+
359
376
@ SuppressWarnings ("resource" )
360
377
protected final void _deserializeAndSet (JsonParser p , DeserializationContext ctxt ,
361
378
Object bean , int index , String typeId ) throws IOException
0 commit comments