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 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.

https://github.com/spring-projects/spring-framework/blob/e4a5d2aaa59266b294e155c4fd80b9ef3e852330/spring-webflux/src/main/java/org/springframework/web/reactive/function/client/DefaultClientResponse.java#L209-L213

Comment From: rstoyanchev

Indeed, assuming ISO_8859_1 as a default fallback is unfortunate.

Comment From: rstoyanchev

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.