Skip to content

Commit a0863bb

Browse files
committed
Merge branch '2.8'
2 parents f4289bb + b64c773 commit a0863bb

2 files changed

Lines changed: 66 additions & 1 deletion

File tree

release-notes/VERSION

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ Project: jackson-databind
295295
(reported by William H)
296296
#1225: `JsonMappingException` should override getProcessor()
297297
(reported by Nick B)
298+
299+
2.6.8 (if ever released)
300+
301+
#1383: Problem with `@JsonCreator` with 1-arg factory-method, implicit param names
302+
303+
2.6.7 (05-Jun-2016)
304+
305+
#1194: Incorrect signature for generic type via `JavaType.getGenericSignature
298306
#1228: @JsonAnySetter does not deserialize null to Deserializer's NullValue
299307
(contributed by Eric S)
300308
#1231: `@JsonSerialize(as=superType)` behavior disallowed in 2.7.4

src/test/java/com/fasterxml/jackson/databind/deser/NullHandlingTest.java

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import java.util.Map;
88

99
import com.fasterxml.jackson.annotation.JsonAnySetter;
10+
import com.fasterxml.jackson.annotation.JsonSubTypes;
11+
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
12+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
1013
import com.fasterxml.jackson.core.*;
1114
import com.fasterxml.jackson.databind.*;
1215
import com.fasterxml.jackson.databind.module.SimpleModule;
@@ -37,9 +40,46 @@ public Map<String,String> getAny(){
3740
return this.any;
3841
}
3942
}
43+
44+
// [databind#1601]
45+
static class RootData {
46+
public String name;
47+
public String type;
48+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
49+
property = "type")
50+
@JsonSubTypes({
51+
@Type(value = TypeA.class, name = "TypeA"),
52+
@Type(value = TypeB.class, name = "TypeB")})
53+
public Proxy proxy;
54+
55+
public RootData() {}
56+
57+
public RootData(String name, String type, Proxy proxy) {
58+
this.name = name;
59+
this.type = type;
60+
this.proxy = proxy;
61+
}
62+
}
63+
static interface Proxy { }
64+
65+
static class TypeA implements Proxy {
66+
public String aValue;
67+
public TypeA() {}
68+
public TypeA(String a) {
69+
this.aValue = a;
70+
}
71+
}
72+
73+
static class TypeB implements Proxy {
74+
public String bValue;
75+
public TypeB() {}
76+
public TypeB(String b) {
77+
this.bValue = b;
78+
}
79+
}
4080

4181
private final ObjectMapper MAPPER = objectMapper();
42-
82+
4383
/*
4484
/**********************************************************
4585
/* Test methods
@@ -144,4 +184,21 @@ public void testMapOfNulls() throws Exception
144184
assertEquals(1, deser.size());
145185
assertEquals("funny", deser.get("key"));
146186
}
187+
188+
// [databind#1601]
189+
public void testPolymorphicDataNull() throws Exception
190+
{
191+
String typeA =
192+
"{\"name\":\"TypeAData\", \"type\":\"TypeA\", \"proxy\":{\"aValue\":\"This works!\"}}";
193+
RootData typeAData = MAPPER.readValue(typeA, RootData.class);
194+
assertEquals("No value for aValue!?", "This works!", ((TypeA) typeAData.proxy).aValue);
195+
String typeB =
196+
"{\"name\":\"TypeBData\", \"type\":\"TypeB\", \"proxy\":{\"bValue\":\"This works too!\"}}";
197+
RootData typeBData = MAPPER.readValue(typeB, RootData.class);
198+
assertEquals("No value for bValue!?", "This works too!", ((TypeB) typeBData.proxy).bValue);
199+
String typeBNull =
200+
"{\"name\":\"TypeBData\", \"type\":\"TypeB\", \"proxy\": null}";
201+
RootData typeBNullData = MAPPER.readValue(typeBNull, RootData.class);
202+
assertNull("Proxy should be null!", typeBNullData.proxy);
203+
}
147204
}

0 commit comments

Comments
 (0)