Skip to content

Commit

Permalink
Fix #928
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Sep 12, 2015
1 parent d485ea7 commit f2f611e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions release-notes/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Project: jackson-databind
#913: ObjectMapper.copy does not preserve MappingJsonFactory features
(reported, fixed by Daniel W)
#922: ObjectMapper.copy() does not preserve _registeredModuleTypes
#928: Problem deserializing External Type Id if type id comes before POJO

2.6.1 (09-Aug-2015)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,9 @@ protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser p, D
SettableBeanProperty creatorProp = creator.findCreatorProperty(propName);
if (creatorProp != null) {
// first: let's check to see if this might be part of value with external type id:
if (ext.handlePropertyValue(p, ctxt, propName, buffer)) {
// 11-Sep-2015, tatu: Important; do NOT pass buffer as last arg, but null,
// since it is not the bean
if (ext.handlePropertyValue(p, ctxt, propName, null)) {
;
} else {
// Last creator property to set?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,12 @@ public Issue222BeanB() { }

// [databind#928]
static class Envelope928 {
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.EXTERNAL_PROPERTY, property="class")
Object payload;
Object _payload;

public Envelope928(@JsonProperty("payload") Object payload) {
this.payload = payload;
public Envelope928(@JsonProperty("payload")
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.EXTERNAL_PROPERTY, property="class")
Object payload) {
_payload = payload;
}
}

Expand Down Expand Up @@ -487,12 +488,12 @@ public void testInverseExternalId928() throws Exception
final String successCase = "{\"payload\":{\"something\":\"test\"},\"class\":\""+CLASS+"\"}";
Envelope928 envelope1 = mapper.readValue(successCase, Envelope928.class);
assertNotNull(envelope1);
assertEquals(Payload928.class, envelope1.payload.getClass());
assertEquals(Payload928.class, envelope1._payload.getClass());

// and then re-ordered case that was problematic
final String failCase = "{\"class\":\""+CLASS+"\",\"payload\":{\"something\":\"test\"}}";
Envelope928 envelope2 = mapper.readValue(failCase, Envelope928.class);
assertNotNull(envelope2);
assertEquals(Payload928.class, envelope2.payload.getClass());
assertEquals(Payload928.class, envelope2._payload.getClass());
}
}

0 comments on commit f2f611e

Please sign in to comment.