Skip to content

WebClientResponseException defaults to ISO-8859-1 #31072

@frasch1712

Description

@frasch1712

Affects: 5.x, 6.x


The default was changed for RestClientResponseException in #23764

org.springframework.web.reactive.function.client.WebClientResponseException still defaults to ISO-8859-1.

	 * Return the response content as a String using the charset of media type
	 * for the response, if available, or otherwise falling back on
	 * {@literal ISO-8859-1}. Use {@link #getResponseBodyAsString(Charset)} if
	 * you want to fall back on a different, default charset.
	 */
	public String getResponseBodyAsString() {
		return getResponseBodyAsString(StandardCharsets.ISO_8859_1);
	}

Shouldn't this also be changed to UTF-8?

Shouldn't org.springframework.web.reactive.function.client.DefaultClientResponse#createException have UTF-8 as default Charset for Responses of type "application/json"? Currently its null.

Charset charset = headers().contentType().map(MimeType::getCharset).orElse(null);

This could also solve the problem.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions