@@ -236,6 +236,20 @@ public Issue222BeanB() { }
236
236
public Issue222BeanB (int value ) { x = value ; }
237
237
}
238
238
239
+ // [databind#928]
240
+ static class Envelope928 {
241
+ @ JsonTypeInfo (use =JsonTypeInfo .Id .CLASS , include =JsonTypeInfo .As .EXTERNAL_PROPERTY , property ="class" )
242
+ Object payload ;
243
+
244
+ public Envelope928 (@ JsonProperty ("payload" ) Object payload ) {
245
+ this .payload = payload ;
246
+ }
247
+ }
248
+
249
+ static class Payload928 {
250
+ public String something ;
251
+ }
252
+
239
253
/*
240
254
/**********************************************************
241
255
/* Unit tests, serialization
@@ -462,4 +476,23 @@ public void testExternalTypeWithProp222() throws Exception
462
476
String json = mapper .writeValueAsString (input );
463
477
assertEquals ("{\" value\" :{\" x\" :13},\" type\" :\" foo\" }" , json );
464
478
}
479
+
480
+ // [databind#928]
481
+ public void testInverseExternalId928 () throws Exception
482
+ {
483
+ final String CLASS = Payload928 .class .getName ();
484
+
485
+ ObjectMapper mapper = new ObjectMapper ();
486
+
487
+ final String successCase = "{\" payload\" :{\" something\" :\" test\" },\" class\" :\" " +CLASS +"\" }" ;
488
+ Envelope928 envelope1 = mapper .readValue (successCase , Envelope928 .class );
489
+ assertNotNull (envelope1 );
490
+ assertEquals (Payload928 .class , envelope1 .payload .getClass ());
491
+
492
+ // and then re-ordered case that was problematic
493
+ final String failCase = "{\" class\" :\" " +CLASS +"\" ,\" payload\" :{\" something\" :\" test\" }}" ;
494
+ Envelope928 envelope2 = mapper .readValue (failCase , Envelope928 .class );
495
+ assertNotNull (envelope2 );
496
+ assertEquals (Payload928 .class , envelope2 .payload .getClass ());
497
+ }
465
498
}
0 commit comments