spring-projects / spring-projects/spring-hateoas
Multiple MappingJackson2HttpMessageConverter's doesn't work
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
After updating from spring-hateoas 1.2 to 1.4, we see some unexpected behavior in our REST endpoints: requests that used to succeed get 415 Unsupported Media Type response, or the format of the json response has changed (links don't end up in the _links field and content does not end up in the _embedded field).
This changed behavior seems to be caused by the changed way in which spring-hateoas deals with HttpMessageConverters. I believe the relevant commit is: https://github.com/spring-projects/spring-hateoas/commit/c561822a4520d8cd4f920b6bea8efff0d2d120a4.
In the case of our application this fails because we have registered a second MappingJackson2HttpMessageConverter, but the code in org.springframework.hateoas.config.WebConfig processes only one of them. See https://github.com/spring-projects/spring-hateoas/blob/1.4.x/src/main/java/org/springframework/hateoas/config/WebConverters.java#L94 . Therefor we end up with one converter that can deal with spring-hateoas-specific objects and one that can't, resulting in the aforementioned change in behavior.
The thing I am unsure about is whether it is correct to have multiple MappingJackson2HttpMessageConverter's. It has served us fine, and I don't see any hints in documentation that you shouldn't do that but still, maybe there is a good reason the code in WebConverters is the way it is.
Could you advise how to proceed? If this is in fact incorrect behavior in spring-hateoas I could provide a fix in a Pull Request, but I am not sure if those are appreciated.
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Start with spring-hateoas 1.4.x's WebConverters.java around line 94 and the related processing in org.springframework.hateoas.config.WebConfig; compare the behavior introduced by commit c561822a4520d8cd4f920b6bea8efff0d2d120a. Reproduce the case with two MappingJackson2HttpMessageConverter instances and verify that REST requests no longer return 415 and that links and content use _links and _embedded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100