76
76
*/
77
77
public abstract class AbstractJackson2HttpMessageConverter extends AbstractGenericHttpMessageConverter <Object > {
78
78
79
- private static final Map <Charset , JsonEncoding > ENCODINGS = jsonEncodings ();
79
+ private static final Map <String , JsonEncoding > ENCODINGS = jsonEncodings ();
80
80
81
81
/**
82
82
* The default charset used by the converter.
@@ -184,7 +184,7 @@ public boolean canWrite(Class<?> clazz, @Nullable MediaType mediaType) {
184
184
}
185
185
if (mediaType != null && mediaType .getCharset () != null ) {
186
186
Charset charset = mediaType .getCharset ();
187
- if (!ENCODINGS .containsKey (charset )) {
187
+ if (!ENCODINGS .containsKey (charset . name () )) {
188
188
return false ;
189
189
}
190
190
}
@@ -247,7 +247,7 @@ private Object readJavaType(JavaType javaType, HttpInputMessage inputMessage) th
247
247
MediaType contentType = inputMessage .getHeaders ().getContentType ();
248
248
Charset charset = getCharset (contentType );
249
249
250
- boolean isUnicode = ENCODINGS .containsKey (charset );
250
+ boolean isUnicode = ENCODINGS .containsKey (charset . name () );
251
251
try {
252
252
if (inputMessage instanceof MappingJacksonInputMessage ) {
253
253
Class <?> deserializationView = ((MappingJacksonInputMessage ) inputMessage ).getDeserializationView ();
@@ -374,7 +374,7 @@ protected JavaType getJavaType(Type type, @Nullable Class<?> contextClass) {
374
374
protected JsonEncoding getJsonEncoding (@ Nullable MediaType contentType ) {
375
375
if (contentType != null && contentType .getCharset () != null ) {
376
376
Charset charset = contentType .getCharset ();
377
- JsonEncoding encoding = ENCODINGS .get (charset );
377
+ JsonEncoding encoding = ENCODINGS .get (charset . name () );
378
378
if (encoding != null ) {
379
379
return encoding ;
380
380
}
@@ -399,9 +399,9 @@ protected Long getContentLength(Object object, @Nullable MediaType contentType)
399
399
return super .getContentLength (object , contentType );
400
400
}
401
401
402
- private static Map <Charset , JsonEncoding > jsonEncodings () {
402
+ private static Map <String , JsonEncoding > jsonEncodings () {
403
403
return EnumSet .allOf (JsonEncoding .class ).stream ()
404
- .collect (Collectors .toMap (encoding -> Charset . forName ( encoding . getJavaName ()) , Function .identity ()));
404
+ .collect (Collectors .toMap (JsonEncoding :: getJavaName , Function .identity ()));
405
405
}
406
406
407
407
}
0 commit comments