-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Use UTF-8 for application/json in MockHttpServletResponse #27846
Conversation
Hi @izeye, Is there an existing issue related to this change? If not, can you please briefly explain the rationale for the change (even if it seems self explanatory to some)? Also, please note that you only changed the code in the test fixture. Thus, you would also need to update |
d376d28
to
bd31fcf
Compare
@sbrannen Thanks for the feedback!
I noticed that
Sorry. I should have looked into it closely, but it seems that I just searched and picked a wrong one. Thanks for guiding me to the right direction. I updated accordingly. Please let me know if there's anything missing or worng. |
No problem. Even core maintainers (like me) often forget to update both versions of those mocks.
You're welcome.
I think that looks pretty good now; however, having looked at the issue in more detail I'm starting to wonder if that is the correct "fix". As far as I know, we don't set the character encoding for the response to UTF-8 in such scenarios in production code (in For the particular test scenario you've described, I see the In other words, I don't think we should make this change to @rstoyanchev and @sdeleuze, what are your thoughts on the matter? |
There is some history. The corresponding MediaType was deprecated in #22788 and removed from use throughout because the charset is no longer defined for application/json. Subsequently, a similar change was considered for MockMvc in #23219 but resulted in a more limited change. I do not think we should revive the charset parameter on application/json anywhere but if there is a specific problem to solve somewhere we can try to be more lenient where it is present or needs to be implied. |
This PR changes to use UTF-8 for
application/json
inMockHttpServletResponse
.