Skip to content

Commit 7783a3b

Browse files
committed
Fix for #2610 by @ashlanderr
1 parent 9700cd6 commit 7783a3b

File tree

5 files changed

+69
-1
lines changed

5 files changed

+69
-1
lines changed

release-notes/CREDITS-2.x

+5
Original file line numberDiff line numberDiff line change
@@ -1032,3 +1032,8 @@ Eduard Tudenhöfner (nastra@github)
10321032
* Reported #2602, contributed fix for: ByteBufferSerializer produces unexpected results with
10331033
a duplicated ByteBuffer and a position > 0
10341034
(2.10.3)
1035+
1036+
Alexander Shilov (ashlanderr@github)
1037+
* Reported, suggested fix for #2610: `EXTERNAL_PROPERTY` doesn't work with `@JsonIgnoreProperties`
1038+
(2.10.3)
1039+

release-notes/VERSION-2.x

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Project: jackson-databind
1212
#2602: ByteBufferSerializer produces unexpected results with a duplicated ByteBuffer
1313
and a position > 0
1414
(reported by Eduard T)
15+
#2610: `EXTERNAL_PROPERTY` doesn't work with `@JsonIgnoreProperties`
16+
(reported, fix suggested by Alexander S)
1517
1618
2.10.2 (05-Jan-2020)
1719

src/main/java/com/fasterxml/jackson/databind/deser/BeanDeserializer.java

+3
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,10 @@ protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser p, D
992992
if (_anySetter != null) {
993993
buffer.bufferAnyProperty(_anySetter, propName,
994994
_anySetter.deserialize(p, ctxt));
995+
continue;
995996
}
997+
// Unknown: let's call handler method
998+
handleUnknownProperty(p, ctxt, _valueClass, propName);
996999
}
9971000
tokens.writeEndObject();
9981001

src/test/java/com/fasterxml/jackson/databind/jsontype/ext/ExternalTypeIdTest.java

-1
Original file line numberDiff line numberDiff line change
@@ -514,7 +514,6 @@ public void testInverseExternalId928() throws Exception
514514
// for [databind#965]
515515
public void testBigDecimal965() throws Exception
516516
{
517-
518517
Wrapper965 w = new Wrapper965();
519518
w.typeEnum = Type965.BIG_DECIMAL;
520519
final String NUM_STR = "-10000000000.0000000001";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package com.fasterxml.jackson.databind.jsontype.ext;
2+
3+
import java.util.List;
4+
5+
import com.fasterxml.jackson.annotation.*;
6+
import com.fasterxml.jackson.core.type.TypeReference;
7+
import com.fasterxml.jackson.databind.*;
8+
9+
public class ExternalTypeIdWithIgnoreUnknownTest extends BaseMapTest
10+
{
11+
// [databind#2611]
12+
@JsonIgnoreProperties(ignoreUnknown = true)
13+
static class Wrapper2611 {
14+
private String type;
15+
16+
@JsonTypeInfo(
17+
use = JsonTypeInfo.Id.NAME,
18+
include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
19+
property = "type",
20+
defaultImpl = Default2611.class
21+
)
22+
private Default2611 data;
23+
24+
@JsonCreator
25+
public Wrapper2611(
26+
@JsonProperty(value = "type", required = true) String type,
27+
@JsonProperty(value = "data", required = true) Default2611 data
28+
) {
29+
this.type = type;
30+
this.data = data;
31+
}
32+
33+
String getType() {
34+
return type;
35+
}
36+
37+
Default2611 getData() {
38+
return data;
39+
}
40+
}
41+
42+
static class Default2611 {}
43+
44+
private final ObjectMapper MAPPER = newJsonMapper();
45+
46+
// [databind#2611]
47+
public void testDeserialization() throws Exception
48+
{
49+
final String data = aposToQuotes("[{'type': 'test','data': {},'additional': {}}]");
50+
51+
List<Wrapper2611> result = MAPPER.readValue(data, new TypeReference<List<Wrapper2611>>() {});
52+
53+
assertEquals(1, result.size());
54+
55+
Wrapper2611 item = result.get(0);
56+
assertEquals("test", item.getType());
57+
assertNotNull(item.getData());
58+
}
59+
}

0 commit comments

Comments
 (0)