Skip to content

Commit 61fe53a

Browse files
committed
Merge branch '2.7' into 2.8
2 parents ab9fcac + 002a9a3 commit 61fe53a

File tree

4 files changed

+68
-6
lines changed

4 files changed

+68
-6
lines changed

release-notes/CREDITS

+4
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,10 @@ Nathanial Ofiesh (ofiesh@github)
571571
* Reported #1441: Failure with custom Enum key deserializer, polymorphic types
572572
(2.8.5)
573573

574+
Frédéric Camblor (fcamblor@github)
575+
* Reported #1451: Type parameter not passed by `ObjectWriter` if serializer pre-fetch disabled
576+
(2.8.6)
577+
574578
Connor Kuhn (ckuhn@github)
575579
* Contributed #1341: FAIL_ON_MISSING_EXTERNAL_TYPE_ID_PROPERTY
576580
(2.9.0)

release-notes/VERSION

+5
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ Project: jackson-databind
134134
#1432: Off by 1 bug in PropertyValueBuffer
135135
(reported by Kevin D)
136136
#1439: NPE when using with filter id, serializing `java.util.Map` types
137+
#1451: Type parameter not passed by `ObjectWriter` if serializer pre-fetch disabled
138+
(reported by Frédéric C)
139+
#1456: `TypeFactory` type resolution broken in 2.7 for generic types
140+
when using `constructType` with context
141+
(reported by Dmitry S)
137142

138143
2.7.8 (26-Sep-2016)
139144

src/main/java/com/fasterxml/jackson/databind/ObjectWriter.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -1401,7 +1401,7 @@ public Prefetch forRootType(ObjectWriter parent, JavaType newType) {
14011401
;
14021402
}
14031403
}
1404-
return new Prefetch(null, null, typeSerializer);
1404+
return new Prefetch(newType, null, typeSerializer);
14051405
}
14061406

14071407
public final JsonSerializer<Object> getValueSerializer() {
@@ -1421,13 +1421,13 @@ public void serialize(JsonGenerator gen, Object value, DefaultSerializerProvider
14211421
{
14221422
if (typeSerializer != null) {
14231423
prov.serializePolymorphic(gen, value, rootType, valueSerializer, typeSerializer);
1424-
return;
1425-
}
1426-
if (valueSerializer != null) {
1424+
} else if (valueSerializer != null) {
14271425
prov.serializeValue(gen, value, rootType, valueSerializer);
1428-
return;
1426+
} else if (rootType != null) {
1427+
prov.serializeValue(gen, value, rootType);
1428+
} else {
1429+
prov.serializeValue(gen, value);
14291430
}
1430-
prov.serializeValue(gen, value);
14311431
}
14321432
}
14331433
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.fasterxml.jackson.databind.jsontype;
2+
3+
import java.util.*;
4+
5+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
6+
import com.fasterxml.jackson.core.type.TypeReference;
7+
import com.fasterxml.jackson.databind.*;
8+
9+
public class PolymorphicList1451SerTest extends BaseMapTest
10+
{
11+
@JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS, include = JsonTypeInfo.As.PROPERTY, property = "@class")
12+
public static class A {
13+
public String a;
14+
}
15+
public static class B extends A {
16+
public String b;
17+
}
18+
19+
private final String CLASS_NAME = getClass().getSimpleName();
20+
21+
public void testCollectionWithTypeInfo() throws Exception {
22+
ObjectMapper mapper = new ObjectMapper()
23+
.disable(SerializationFeature.EAGER_SERIALIZER_FETCH)
24+
// .disable(DeserializationFeature.EAGER_DESERIALIZER_FETCH)
25+
;
26+
27+
List<A> input = new ArrayList<A>();
28+
A a = new A();
29+
a.a = "a1";
30+
input.add(a);
31+
32+
B b = new B();
33+
b.b = "b";
34+
b.a = "a2";
35+
input.add(b);
36+
37+
final TypeReference<?> typeRef =
38+
new TypeReference<Collection<A>>(){};
39+
ObjectWriter writer = mapper.writerFor(typeRef);
40+
41+
String result = writer.writeValueAsString(input);
42+
43+
assertEquals(aposToQuotes(
44+
"[{'@class':'."+CLASS_NAME+"$A','a':'a1'},{'@class':'."+CLASS_NAME+"$B','a':'a2','b':'b'}]"
45+
), result);
46+
47+
List<A> output = mapper.readerFor(typeRef)
48+
.readValue(result);
49+
assertEquals(2, output.size());
50+
assertEquals(A.class, output.get(0).getClass());
51+
assertEquals(B.class, output.get(1).getClass());
52+
}
53+
}

0 commit comments

Comments
 (0)