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.
This commit is contained in:
Oliver Drotbohm
2024-11-15 08:36:27 +01:00
parent 1ddf819a79
commit 6a5787b3f3

View File

@@ -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;
}