Skip to content

Commit

Permalink
Merge branch '2.14' into 2.15
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed May 16, 2023
2 parents a7e17ad + c7b6c64 commit 55d87cf
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
4 changes: 3 additions & 1 deletion release-notes/VERSION-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ Project: jackson-databind
=== Releases ===
------------------------------------------------------------------------

2.15.1 (not yet released)
2.15.1 (16-May-2023)

#3882: Error in creating nested `ArrayNode`s with `JsonNode.withArray()`
(reported by @SaiKrishna369)
#3894: Only avoid Records fields detection for deserialization
(contributed by Sim Y-T)
#3895: 2.15.0 breaking behaviour change for records and Getter Visibility
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ protected ArrayNode _withArrayAddTailElement(JsonPointer tail, boolean preferInd
_withXxxSetArrayElement(index, next);
return next._withArrayAddTailElement(tail, preferIndex);
}
ArrayNode next = this.arrayNode();
ObjectNode next = this.objectNode();
_withXxxSetArrayElement(index, next);
return next._withArrayAddTailElement(tail, preferIndex);
return next._withArrayAddTailProperty(tail, preferIndex);
}

protected void _withXxxSetArrayElement(int index, JsonNode value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.JsonNode.OverwriteMode;

// for [databuind#1980] implementation
// for [databind#1980] implementation
public class WithPathTest extends BaseMapTest
{
private final ObjectMapper MAPPER = sharedMapper();
Expand Down Expand Up @@ -296,4 +296,23 @@ private void _verifyArrayReplaceFail(JsonNode doc, JsonPointer ptr, OverwriteMod
verifyException(e, "(mode `OverwriteMode."+mode.name()+"`)");
}
}

// [databind#3882]
public void testWithArray3882() throws Exception
{
ObjectNode root = MAPPER.createObjectNode();
ArrayNode aN = root.withArray("/key/0/a",
JsonNode.OverwriteMode.ALL, true);
aN.add(123);
assertEquals(a2q("{'key':[{'a':[123]}]}"),
root.toString());

// And then the original case
root = MAPPER.createObjectNode();
aN = root.withArray(JsonPointer.compile("/key1/array1/0/element1"),
JsonNode.OverwriteMode.ALL, true);
aN.add("v1");
assertEquals(a2q("{'key1':{'array1':[{'element1':['v1']}]}}"),
root.toString());
}
}

0 comments on commit 55d87cf

Please sign in to comment.