Skip to content

Commit b64c773

Browse files
committed
Merge branch '2.7' into 2.8
2 parents 262961a + 28ec8a4 commit b64c773

File tree

2 files changed

+66
-1
lines changed

2 files changed

+66
-1
lines changed

release-notes/VERSION

+8
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,14 @@ Project: jackson-databind
224224
(reported by William H)
225225
#1225: `JsonMappingException` should override getProcessor()
226226
(reported by Nick B)
227+
228+
2.6.8 (if ever released)
229+
230+
#1383: Problem with `@JsonCreator` with 1-arg factory-method, implicit param names
231+
232+
2.6.7 (05-Jun-2016)
233+
234+
#1194: Incorrect signature for generic type via `JavaType.getGenericSignature
227235
#1228: @JsonAnySetter does not deserialize null to Deserializer's NullValue
228236
(contributed by Eric S)
229237
#1231: `@JsonSerialize(as=superType)` behavior disallowed in 2.7.4

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

+58-1
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.deser.JDKScalarsTest.PrimitivesBean;
@@ -38,9 +41,46 @@ public Map<String,String> getAny(){
3841
return this.any;
3942
}
4043
}
44+
45+
// [databind#1601]
46+
static class RootData {
47+
public String name;
48+
public String type;
49+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
50+
property = "type")
51+
@JsonSubTypes({
52+
@Type(value = TypeA.class, name = "TypeA"),
53+
@Type(value = TypeB.class, name = "TypeB")})
54+
public Proxy proxy;
55+
56+
public RootData() {}
57+
58+
public RootData(String name, String type, Proxy proxy) {
59+
this.name = name;
60+
this.type = type;
61+
this.proxy = proxy;
62+
}
63+
}
64+
static interface Proxy { }
65+
66+
static class TypeA implements Proxy {
67+
public String aValue;
68+
public TypeA() {}
69+
public TypeA(String a) {
70+
this.aValue = a;
71+
}
72+
}
73+
74+
static class TypeB implements Proxy {
75+
public String bValue;
76+
public TypeB() {}
77+
public TypeB(String b) {
78+
this.bValue = b;
79+
}
80+
}
4181

4282
private final ObjectMapper MAPPER = objectMapper();
43-
83+
4484
/*
4585
/**********************************************************
4686
/* Test methods
@@ -221,4 +261,21 @@ public void testMapOfNulls() throws Exception
221261
assertEquals(1, deser.size());
222262
assertEquals("funny", deser.get("key"));
223263
}
264+
265+
// [databind#1601]
266+
public void testPolymorphicDataNull() throws Exception
267+
{
268+
String typeA =
269+
"{\"name\":\"TypeAData\", \"type\":\"TypeA\", \"proxy\":{\"aValue\":\"This works!\"}}";
270+
RootData typeAData = MAPPER.readValue(typeA, RootData.class);
271+
assertEquals("No value for aValue!?", "This works!", ((TypeA) typeAData.proxy).aValue);
272+
String typeB =
273+
"{\"name\":\"TypeBData\", \"type\":\"TypeB\", \"proxy\":{\"bValue\":\"This works too!\"}}";
274+
RootData typeBData = MAPPER.readValue(typeB, RootData.class);
275+
assertEquals("No value for bValue!?", "This works too!", ((TypeB) typeBData.proxy).bValue);
276+
String typeBNull =
277+
"{\"name\":\"TypeBData\", \"type\":\"TypeB\", \"proxy\": null}";
278+
RootData typeBNullData = MAPPER.readValue(typeBNull, RootData.class);
279+
assertNull("Proxy should be null!", typeBNullData.proxy);
280+
}
224281
}

0 commit comments

Comments
 (0)