spring-projects / spring-projects/spring-data-rest
Bug with a cast between MappingJacksonValue and RepresentationModel in HalFormsAdaptingResponseBodyAdvice?
@odrotbohm is already working on this.
Since May 23, 2022.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
A strange behavior occurred when I tried to migrate an older springboot project. I received the following error message:
class org.springframework.http.converter.json.MappingJacksonValue cannot be cast to class org.springframework.hateoas.RepresentationModel (org.springframework.http.converter.json.MappingJacksonValue and org.springframework.hateoas.RepresentationModel are in unnamed module of loader 'app')
I had implemented a ControllerAdvice using the class AbstractMappingJacksonResponseBodyAdvice.
AbstractMappingJacksonResponseBodyAdvice class
In this case, the body is no longer just an Object, but a MappingJacksonValue.
With spring-data-rest-mvc, I have a chain of advises. HalFormsAdaptingResponseBodyAdvice uses a RepresentationModel, but AbstractMappingJacksonResponseBodyAdvice changes the type.
HalFormsAdaptingResponseBodyAdvice class
The spring-data-rest-mvc version 3.5.5 does not work with my feature that filtered the JSON with a controllerAdvise.
How can I fix it? Do you know if it's a bug?
Thank you for your help
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.