diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java index 5df73fbdd..81bfbcc70 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/DomainObjectReader.java @@ -402,7 +402,7 @@ private boolean handleArrayNode(ArrayNode array, Collection collection, if (ObjectNode.class.isInstance(jsonNode)) { nestedObjectFound = true; - doMerge((ObjectNode) jsonNode, next, mapper); + readPut((ObjectNode) jsonNode, next, mapper); } } diff --git a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java index 2d588bf20..1129bbebe 100755 --- a/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java +++ b/spring-data-rest-webmvc/src/test/java/org/springframework/data/rest/webmvc/json/DomainObjectReaderUnitTests.java @@ -237,8 +237,9 @@ void doesNotApplyInputToReadOnlyFields() throws Exception { assertThat(reader.readPut(node, sample, mapper).createdDate).isEqualTo(reference); } - @Test // DATAREST-931 - void readsPatchForEntityNestedInCollection() throws Exception { + @Test // DATAREST-931, GH-2358 + // https://datatracker.ietf.org/doc/html/rfc7386#section-2 + void handlesEntityNestedInAnArrayLikePutForPatchRequest() throws Exception { Phone phone = new Phone(); phone.creationDate = new GregorianCalendar(); @@ -251,7 +252,7 @@ void readsPatchForEntityNestedInCollection() throws Exception { User result = reader.read(source, user, new ObjectMapper()); - assertThat(result.phones.get(0).creationDate).isNotNull(); + assertThat(result.phones.get(0).creationDate).isNull(); } @Test // DATAREST-919