-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Default content type of response changed in v5.3.11 #27573
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've tracked this change down to #27488. When Spring MVC takes the producible media types and sorts them by specificity and quality, we're getting the following order in the sorted list:
This explains the behavior change you're seeing. Arguably, not expressing any opinion in the request nor on the controller handler exposed you to an order that's outside of your control and both 5.3.10 or 5.3.11 behaviors are acceptable with the opinions expressed here. The new ordering looks fine and predictable to me and I don't know how we can roll this back without breaking the fix made in #27488. I'll let @poutsma comment here in case I've missed something, but otherwise I think this issue should be closed. |
@bclozel is correct in saying that the problem at hand is not expressing any media type preference, either through Accept header, suffix, or request parameter (see https://docs.spring.io/spring-framework/docs/current/reference/html/web.html#mvc-config-content-negotiation). If you have any control over the client code, I would strongly suggest to improve this. Or, if you simply don't want to return XML, to disable XML support in your configuration. That said, we do recognize that changing the default content-type in a minor release can be inconvenient, so we have reverted the changes that caused this issue. |
Until Spring Framework v5.3.10, when
Accept
header is not specified, all API usedContent-Type: application/json
as default value. This behavior seems to have changed in v5.3.11 whereContent-Type: application/xml
is being used.Please refer attached demo.zip.
When following command is used to trigger HTTP request, different responses are returned by API with
v5.3.10
andv5.3.11
.Spring Framework <= v5.3.10
Spring Framework v5.3.11
The text was updated successfully, but these errors were encountered: