From 6a5787b3f338e02fcc50a68d5d56ce1c104faccb Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Fri, 15 Nov 2024 08:36:27 +0100 Subject: [PATCH] Fix HttpMessageConverter lookup in PersistentEntityResourceHandlerMethodArgumentResolver. We now ask the candidate converters whether they can read RepresentationModel instead of the domain type as that's the key type we register the individual ObjectMappers for in Spring HATEOAS. Fixes: GH-2425. Related ticket: GH-2419. --- .../PersistentEntityResourceHandlerMethodArgumentResolver.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/PersistentEntityResourceHandlerMethodArgumentResolver.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/PersistentEntityResourceHandlerMethodArgumentResolver.java index 43b02fe45..250cb94ab 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/PersistentEntityResourceHandlerMethodArgumentResolver.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/PersistentEntityResourceHandlerMethodArgumentResolver.java @@ -39,6 +39,7 @@ import org.springframework.data.rest.webmvc.RootResourceInformation; import org.springframework.data.rest.webmvc.json.BindContextFactory; import org.springframework.data.rest.webmvc.json.DomainObjectReader; import org.springframework.data.rest.webmvc.support.BackendIdHandlerMethodArgumentResolver; +import org.springframework.hateoas.RepresentationModel; import org.springframework.http.MediaType; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.HttpMessageNotReadableException; @@ -114,7 +115,7 @@ public class PersistentEntityResourceHandlerMethodArgumentResolver implements Ha for (HttpMessageConverter converter : messageConverters) { - if (!converter.canRead(domainType, contentType)) { + if (!converter.canRead(RepresentationModel.class, contentType)) { continue; }