Skip to content

Commit bad8803

Browse files
committed
Merge branch 'master' into ng-3.0
2 parents b69760a + 5254c37 commit bad8803

File tree

3 files changed

+81
-6
lines changed

3 files changed

+81
-6
lines changed

release-notes/VERSION

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Project: jackson-databind
33
=== Releases ===
44
------------------------------------------------------------------------
55

6-
2.9.1 (not yet released)
6+
2.9.1 (07-Sep-2017)
77

88
#1705: Non-generic interface method hides type resolution info from generic base class
99
(reported by Tim B)
@@ -21,6 +21,7 @@ Project: jackson-databind
2121
(contributed by Bertrand R)
2222
- Fix `DelegatingDeserializer` constructor to pass `handledType()` (and
2323
not type of deserializer being delegated to!)
24+
- Add `Automatic-Module-Name` ("com.fasterxml.jackson.databind") for JDK 9 module system
2425

2526
2.9.0 (30-Jul-2017)
2627

src/test/java/com/fasterxml/jackson/databind/jsontype/TestNoTypeInfo.java renamed to src/test/java/com/fasterxml/jackson/databind/jsontype/NoTypeInfoTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import com.fasterxml.jackson.databind.*;
66
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
77

8-
public class TestNoTypeInfo extends BaseMapTest
8+
public class NoTypeInfoTest extends BaseMapTest
99
{
1010
@JsonTypeInfo(use=JsonTypeInfo.Id.NONE)
1111
@JsonDeserialize(as=NoType.class)
@@ -15,17 +15,16 @@ static interface NoTypeInterface {
1515
final static class NoType implements NoTypeInterface {
1616
public int a = 3;
1717
}
18-
18+
1919
/*
2020
/**********************************************************
21-
/* Unit tests
21+
/* Test methods
2222
/**********************************************************
2323
*/
2424

25-
// for [JACKSON-746]
2625
public void testWithIdNone() throws Exception
2726
{
28-
final ObjectMapper mapper = new ObjectMapper();
27+
final ObjectMapper mapper = newObjectMapper();
2928
mapper.enableDefaultTyping();
3029
// serialize without type info
3130
String json = mapper.writeValueAsString(new NoType());
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
package com.fasterxml.jackson.failing;
2+
3+
import java.io.IOException;
4+
import java.util.*;
5+
6+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
7+
import com.fasterxml.jackson.core.JsonParser;
8+
import com.fasterxml.jackson.databind.*;
9+
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
10+
11+
public class NoTypeInfo1654Test extends BaseMapTest
12+
{
13+
// [databind#1654]
14+
15+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME)
16+
static class Value1654 {
17+
public int x;
18+
19+
protected Value1654() { }
20+
public Value1654(int x) { this.x = x; }
21+
}
22+
23+
static class Value1654TypedContainer {
24+
public List<Value1654> values;
25+
26+
protected Value1654TypedContainer() { }
27+
public Value1654TypedContainer(Value1654... v) {
28+
values = Arrays.asList(v);
29+
}
30+
}
31+
32+
static class Value1654UntypedContainer {
33+
@JsonDeserialize(contentUsing = Value1654Deserializer.class)
34+
@JsonTypeInfo(use = JsonTypeInfo.Id.NONE)
35+
public List<Value1654> values;
36+
}
37+
38+
static class Value1654Deserializer extends JsonDeserializer<Value1654> {
39+
@Override
40+
public Value1654 deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
41+
p.skipChildren();
42+
return new Value1654(13);
43+
}
44+
}
45+
46+
/*
47+
/**********************************************************
48+
/* Test methods
49+
/**********************************************************
50+
*/
51+
52+
// [databind#1654]
53+
public void testNoTypeElementOverride() throws Exception
54+
{
55+
final ObjectMapper mapper = newObjectMapper();
56+
57+
// First: regular typed case
58+
String json = mapper.writeValueAsString(new Value1654TypedContainer(
59+
new Value1654(1),
60+
new Value1654(2),
61+
new Value1654(3)
62+
));
63+
Value1654TypedContainer result = mapper.readValue(json, Value1654TypedContainer.class);
64+
assertEquals(3, result.values.size());
65+
assertEquals(2, result.values.get(1).x);
66+
67+
// and then actual failing case
68+
final String noTypeJson = aposToQuotes(
69+
"{'values':[{'x':3},{'x': 7}] }"
70+
);
71+
Value1654UntypedContainer unResult = mapper.readValue(noTypeJson, Value1654UntypedContainer.class);
72+
assertEquals(2, unResult.values.size());
73+
assertEquals(7, unResult.values.get(1).x);
74+
}
75+
}

0 commit comments

Comments
 (0)