Skip to content

Commit

Permalink
Fix for #2610 by @ashlanderr
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 1, 2020
1 parent 9700cd6 commit 7783a3b
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 1 deletion.
5 changes: 5 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1032,3 +1032,8 @@ Eduard Tudenhöfner (nastra@github)
* Reported #2602, contributed fix for: ByteBufferSerializer produces unexpected results with
a duplicated ByteBuffer and a position > 0
(2.10.3)
Alexander Shilov (ashlanderr@github)
* Reported, suggested fix for #2610: `EXTERNAL_PROPERTY` doesn't work with `@JsonIgnoreProperties`
(2.10.3)

2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Project: jackson-databind
#2602: ByteBufferSerializer produces unexpected results with a duplicated ByteBuffer
and a position > 0
(reported by Eduard T)
#2610: `EXTERNAL_PROPERTY` doesn't work with `@JsonIgnoreProperties`
(reported, fix suggested by Alexander S)
2.10.2 (05-Jan-2020)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,10 @@ protected Object deserializeUsingPropertyBasedWithExternalTypeId(JsonParser p, D
if (_anySetter != null) {
buffer.bufferAnyProperty(_anySetter, propName,
_anySetter.deserialize(p, ctxt));
continue;
}
// Unknown: let's call handler method
handleUnknownProperty(p, ctxt, _valueClass, propName);
}
tokens.writeEndObject();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,6 @@ public void testInverseExternalId928() throws Exception
// for [databind#965]
public void testBigDecimal965() throws Exception
{

Wrapper965 w = new Wrapper965();
w.typeEnum = Type965.BIG_DECIMAL;
final String NUM_STR = "-10000000000.0000000001";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.fasterxml.jackson.databind.jsontype.ext;

import java.util.List;

import com.fasterxml.jackson.annotation.*;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;

public class ExternalTypeIdWithIgnoreUnknownTest extends BaseMapTest
{
// [databind#2611]
@JsonIgnoreProperties(ignoreUnknown = true)
static class Wrapper2611 {
private String type;

@JsonTypeInfo(
use = JsonTypeInfo.Id.NAME,
include = JsonTypeInfo.As.EXTERNAL_PROPERTY,
property = "type",
defaultImpl = Default2611.class
)
private Default2611 data;

@JsonCreator
public Wrapper2611(
@JsonProperty(value = "type", required = true) String type,
@JsonProperty(value = "data", required = true) Default2611 data
) {
this.type = type;
this.data = data;
}

String getType() {
return type;
}

Default2611 getData() {
return data;
}
}

static class Default2611 {}

private final ObjectMapper MAPPER = newJsonMapper();

// [databind#2611]
public void testDeserialization() throws Exception
{
final String data = aposToQuotes("[{'type': 'test','data': {},'additional': {}}]");

List<Wrapper2611> result = MAPPER.readValue(data, new TypeReference<List<Wrapper2611>>() {});

assertEquals(1, result.size());

Wrapper2611 item = result.get(0);
assertEquals("test", item.getType());
assertNotNull(item.getData());
}
}

0 comments on commit 7783a3b

Please sign in to comment.