From 385c97db9f2a4a0ee2934fa5f7e5fd637f26d3aa 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 | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 eda3fd768f1..32065548451 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 @@ -1,5 +1,5 @@ /* - * Copyright 2002-2018 the original author or authors. + * Copyright 2002-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -284,7 +284,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 Charset getCharset(@Nullable MediaType contentType) { if (contentType != null && contentType.getCharset() != null) { return contentType.getCharset(); }