From 011aad0d663b0a114cbbc8ba3af2cdd71bdfc109 Mon Sep 17 00:00:00 2001 From: Mark Paluch Date: Thu, 15 Jun 2023 17:11:27 +0200 Subject: [PATCH] Polishing. Fix backport to use isPresent instead of isEmpty. See #2264 --- .../data/rest/webmvc/json/DomainObjectReader.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) 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 82c03deab..94b75e14a 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 @@ -685,9 +685,8 @@ public class DomainObjectReader { result = mergeCollections(property, sourceValue, targetValue, mapper); } else if (property.isEntity()) { - result = targetValue.isEmpty() - ? sourceValue - : targetValue.flatMap(t -> sourceValue.map(s -> mergeForPut(s, t, mapper))); + result = targetValue.isPresent() ? targetValue.flatMap(t -> sourceValue.map(s -> mergeForPut(s, t, mapper))) + : sourceValue; } else { result = sourceValue; }