Skip to content

Commit 28ec8a4

Browse files
committed
Merge branch '2.6' into 2.7
2 parents 6b9782b + 96eb83b commit 28ec8a4

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

release-notes/VERSION

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,14 @@ Project: jackson-databind
7676
(reported by William H)
7777
#1225: `JsonMappingException` should override getProcessor()
7878
(reported by Nick B)
79+
80+
2.6.8 (if ever released)
81+
82+
#1383: Problem with `@JsonCreator` with 1-arg factory-method, implicit param names
83+
84+
2.6.7 (05-Jun-2016)
85+
86+
#1194: Incorrect signature for generic type via `JavaType.getGenericSignature
7987
#1228: @JsonAnySetter does not deserialize null to Deserializer's NullValue
8088
(contributed by Eric S)
8189
#1231: `@JsonSerialize(as=superType)` behavior disallowed in 2.7.4

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

Lines changed: 57 additions & 0 deletions
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;
@@ -38,6 +41,43 @@ public Map<String,String> getAny(){
3841
}
3942
}
4043

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+
}
80+
4181
/*
4282
/**********************************************************
4383
/* Test methods
@@ -136,4 +176,21 @@ public void testMapOfNulls() throws Exception
136176
assertEquals(1, deser.size());
137177
assertEquals("funny", deser.get("key"));
138178
}
179+
180+
// [databind#1601]
181+
public void testPolymorphicDataNull() throws Exception {
182+
ObjectMapper mapper = new ObjectMapper();
183+
String typeA =
184+
"{\"name\":\"TypeAData\", \"type\":\"TypeA\", \"proxy\":{\"aValue\":\"This works!\"}}";
185+
RootData typeAData = mapper.readValue(typeA, RootData.class);
186+
assertEquals("No value for aValue!?", "This works!", ((TypeA) typeAData.proxy).aValue);
187+
String typeB =
188+
"{\"name\":\"TypeBData\", \"type\":\"TypeB\", \"proxy\":{\"bValue\":\"This works too!\"}}";
189+
RootData typeBData = mapper.readValue(typeB, RootData.class);
190+
assertEquals("No value for bValue!?", "This works too!", ((TypeB) typeBData.proxy).bValue);
191+
String typeBNull =
192+
"{\"name\":\"TypeBData\", \"type\":\"TypeB\", \"proxy\": null}";
193+
RootData typeBNullData = mapper.readValue(typeBNull, RootData.class);
194+
assertNull("Proxy should be null!", typeBNullData.proxy);
195+
}
139196
}

0 commit comments

Comments
 (0)