Skip to content

Commit

Permalink
Update release notes wrt #3699
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Dec 20, 2022
1 parent 68ef028 commit 0020fcb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
4 changes: 4 additions & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -1528,3 +1528,7 @@ Moritz Halbritter (mhalbritter@github)
* Reported #3665: `ObjectMapper` default heap consumption increased significantly
from 2.13.x to 2.14.0
(2.14.1)
Philippe Marschall (marschall@github)
* Contributed #3699: Allow custom `JsonNode` implementations
(2.14.2)
2 changes: 2 additions & 0 deletions release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Project: jackson-databind

#1751: `@JsonTypeInfo` does not work if the Type Id is an Integer value
(reported by @marvin-we)
#3699: Allow custom `JsonNode` implementations
(contributed by Philippe M)

2.14.1 (21-Nov-2022)

Expand Down
27 changes: 17 additions & 10 deletions src/test/java/com/fasterxml/jackson/databind/ObjectReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -523,16 +523,18 @@ public boolean handleUnknownProperty(DeserializationContext ctxt, JsonParser p,
return true;
}
}).build();
A aObject = mapper.readValue("{\"unknownField\" : 1, \"knownField\": \"test\"}", A.class);
A2297 aObject = mapper.readValue("{\"unknownField\" : 1, \"knownField\": \"test\"}",
A2297.class);

assertEquals("test", aObject.knownField);
}

private static class A {
// For [databind#2297]
private static class A2297 {
String knownField;

@JsonCreator
private A(@JsonProperty("knownField") String knownField) {
private A2297(@JsonProperty("knownField") String knownField) {
this.knownField = knownField;
}
}
Expand All @@ -551,15 +553,18 @@ public void testCustomObjectNode() throws Exception
public void testCustomArrayNode() throws Exception
{
ArrayNode defaultNode = (ArrayNode) MAPPER.readTree("[{\"x\": 1, \"y\": 2}]");
CustomArrayNode customArrayNode = new CustomArrayNode(defaultNode);
DelegatingArrayNode customArrayNode = new DelegatingArrayNode(defaultNode);
Point[] points = MAPPER.readerFor(Point[].class).readValue(customArrayNode);
Point point = points[0];
assertEquals(1, point.x);
assertEquals(2, point.y);
}

// for [databind#3699]
static class CustomObjectNode extends BaseJsonNode
{
private static final long serialVersionUID = 1L;

private final ObjectNode _delegate;

CustomObjectNode(ObjectNode delegate) {
Expand Down Expand Up @@ -681,11 +686,14 @@ public int hashCode() {

}

static class CustomArrayNode extends BaseJsonNode
// for [databind#3699]
static class DelegatingArrayNode extends BaseJsonNode
{
private static final long serialVersionUID = 1L;

private final ArrayNode _delegate;

CustomArrayNode(ArrayNode delegate) {
DelegatingArrayNode(ArrayNode delegate) {
this._delegate = delegate;
}

Expand Down Expand Up @@ -722,7 +730,7 @@ public void serializeWithType(JsonGenerator g, SerializerProvider ctxt, TypeSeri
@Override
@SuppressWarnings("unchecked")
public <T extends JsonNode> T deepCopy() {
return (T) new CustomArrayNode(_delegate);
return (T) new DelegatingArrayNode(_delegate);
}

@Override
Expand Down Expand Up @@ -785,17 +793,16 @@ public boolean equals(Object o) {
if (o == this) {
return true;
}
if (!(o instanceof CustomArrayNode)) {
if (!(o instanceof DelegatingArrayNode)) {
return false;
}
CustomArrayNode other = (CustomArrayNode) o;
DelegatingArrayNode other = (DelegatingArrayNode) o;
return this._delegate.equals(other._delegate);
}

@Override
public int hashCode() {
return _delegate.hashCode();
}

}
}

0 comments on commit 0020fcb

Please sign in to comment.