-
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
MockMvc no longer handles UTF-8 characters #23219
Comments
@sbrannen @rstoyanchev The situation here is the following. As expected, the JSON data is written as UTF-8 by Jackson converter/encoder regardless of the On In order to get a more predictable behavior, I think my proposal would be to change: public String getContentAsString() throws UnsupportedEncodingException {
return (this.characterEncoding != null ?
this.content.toString(this.characterEncoding) : this.content.toString());
} to public String getContentAsString() throws UnsupportedEncodingException {
return (this.characterEncoding != null && this.charset ?
this.content.toString(this.characterEncoding) : this.content.toString());
} in order to only use Any thoughts? |
What about making a change in |
I am not sure because |
@sdeleuze I think |
@sdeleuze Thanks for fixing this bug. However, the same bug exists for Should I open a new issue and provide a project to reproduce the problem? |
yes please |
I had to read from |
I wrote simple controller:
Also very simple tutorial-like test:
The test fails in version 5.2.0.M3 now. Test passes in the previous milestone version 5.2.0.M2 and earlier versions.
The issue is somehow related to deprecation of
org.springframework.http.MediaType#APPLICATION_JSON_UTF8_VALUE
.Of course it is possible to fix the test by adding accept but I rather do not do that, because
APPLICATION_JSON_UTF8_VALUE
is deprecated now.I have also prepared simple maven project to simulate the problem.
springutf8.zip
It seems to me, that
MockMvc
client does not handle UTF-8 characters well, like other modern browsers.The text was updated successfully, but these errors were encountered: