You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Web client should throw an WebClientResponseException when http response status is 4xx, which is created by clientResponse.createException(), if the error response is JSON string, the media type should be application/json, that should decode http response body using UTF-8 encoding by default, but current using ISO-8859-1 for all media types. it causes body field in the generated exception contains malformed characters.
I made change where you can pass the fallback Charset to use into the getResponseBodyAsString method of WebClientResponseException. I'm afraid that's as far as we can go in a 5.3.7 release. Perhaps in a future major or minor version we can change the default. For extra context, indeed a JSON response should be UTF-8 but following a similar change in other areas, we had plenty of feedback about JSON responses that aren't UTF-8 beyond a client's control.
rstoyanchev
changed the title
Wrong charset used when creating exception from WebClient DefaltClientResponse
Provide control over fallack charset to use in WebClientResponseException
May 6, 2021
jhoeller
changed the title
Provide control over fallack charset to use in WebClientResponseException
Provide control over fallback charset to use in WebClientResponseException
May 11, 2021
Affects: 5.3.6
Web client should throw an WebClientResponseException when http response status is 4xx, which is created by
clientResponse.createException()
, if the error response is JSON string, the media type should beapplication/json
, that should decode http response body using UTF-8 encoding by default, but current using ISO-8859-1 for all media types. it causes body field in the generated exception contains malformed characters.spring-framework/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java
Lines 209 to 213 in e4a5d2a
The text was updated successfully, but these errors were encountered: