@@ -151,6 +151,9 @@ protected final Object _deserializeOther(JsonParser p, DeserializationContext ct
151
151
case VALUE_TRUE :
152
152
case VALUE_FALSE :
153
153
return deserializeFromBoolean (p , ctxt );
154
+
155
+ case VALUE_NULL :
156
+ return deserializeFromNull (p , ctxt );
154
157
case START_ARRAY :
155
158
// these only work if there's a (delegating) creator...
156
159
return deserializeFromArray (p , ctxt );
@@ -164,8 +167,8 @@ protected final Object _deserializeOther(JsonParser p, DeserializationContext ct
164
167
}
165
168
return deserializeFromObject (p , ctxt );
166
169
default :
167
- throw ctxt .mappingException (handledType ());
168
170
}
171
+ throw ctxt .mappingException (handledType ());
169
172
}
170
173
171
174
protected Object _missingToken (JsonParser p , DeserializationContext ctxt ) throws IOException {
@@ -467,6 +470,35 @@ protected final Object _deserializeWithErrorWrapping(JsonParser p,
467
470
}
468
471
}
469
472
473
+ /**
474
+ * Helper method called for rare case of pointing to {@link JsonToken#VALUE_NULL}
475
+ * token. While this is most often an erroneous condition, there is one specific
476
+ * case with XML handling where polymorphic type with no properties is exposed
477
+ * as such, and should be handled same as empty Object.
478
+ *
479
+ * @since 2.7
480
+ */
481
+ protected Object deserializeFromNull (JsonParser p , DeserializationContext ctxt )
482
+ throws IOException
483
+ {
484
+ // 17-Dec-2015, tatu: Highly specialized case, mainly to support polymorphic
485
+ // "empty" POJOs deserialized from XML, where empty XML tag synthesizes a
486
+ // `VALUE_NULL` token.
487
+ if (p .requiresCustomCodec ()) { // not only XML module, but mostly it...
488
+ @ SuppressWarnings ("resource" )
489
+ TokenBuffer tb = new TokenBuffer (p , ctxt );
490
+ tb .writeEndObject ();
491
+ JsonParser p2 = tb .asParser (p );
492
+ p2 .nextToken (); // to point to END_OBJECT
493
+ // note: don't have ObjectId to consider at this point, so:
494
+ Object ob = _vanillaProcessing ? vanillaDeserialize (p2 , ctxt , JsonToken .END_OBJECT )
495
+ : deserializeFromObject (p2 , ctxt );
496
+ p2 .close ();
497
+ return ob ;
498
+ }
499
+ throw ctxt .mappingException (handledType ());
500
+ }
501
+
470
502
/*
471
503
/**********************************************************
472
504
/* Deserializing when we have to consider an active View
0 commit comments