From b6ff12d2f5a140785611f46ba6af2f36c1785d49 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Mon, 7 Sep 2020 17:34:01 +0100 Subject: [PATCH] Expose protected method in AbstractJackson2HttpMessageConverter Closes gh-25509 --- .../json/AbstractJackson2HttpMessageConverter.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java index 8a6d2023000..78ca9fb8d31 100644 --- a/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java +++ b/spring-web/src/main/java/org/springframework/http/converter/json/AbstractJackson2HttpMessageConverter.java @@ -285,7 +285,15 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener } } - private static Charset getCharset(@Nullable MediaType contentType) { + /** + * Return the charset to use for JSON input. + *

By default this is either the charset from the input {@code MediaType} + * or otherwise falling back on {@code UTF-8}. + * @param contentType the content type of the HTTP input message + * @return the charset to use + * @since 5.1.18 + */ + protected static Charset getCharset(@Nullable MediaType contentType) { if (contentType != null && contentType.getCharset() != null) { return contentType.getCharset(); }