AbstractJackson2HttpMessageConverter.java (spring-framework-5.3.23) | : | AbstractJackson2HttpMessageConverter.java (spring-framework-5.3.24) | ||
---|---|---|---|---|
skipping to change at line 354 | skipping to change at line 354 | |||
JavaType javaType = getJavaType(clazz, null); | JavaType javaType = getJavaType(clazz, null); | |||
return readJavaType(javaType, inputMessage); | return readJavaType(javaType, inputMessage); | |||
} | } | |||
private Object readJavaType(JavaType javaType, HttpInputMessage inputMess age) throws IOException { | private Object readJavaType(JavaType javaType, HttpInputMessage inputMess age) throws IOException { | |||
MediaType contentType = inputMessage.getHeaders().getContentType( ); | MediaType contentType = inputMessage.getHeaders().getContentType( ); | |||
Charset charset = getCharset(contentType); | Charset charset = getCharset(contentType); | |||
ObjectMapper objectMapper = selectObjectMapper(javaType.getRawCla ss(), contentType); | ObjectMapper objectMapper = selectObjectMapper(javaType.getRawCla ss(), contentType); | |||
Assert.state(objectMapper != null, "No ObjectMapper for " + javaT ype); | Assert.state(objectMapper != null, () -> "No ObjectMapper for " + javaType); | |||
boolean isUnicode = ENCODINGS.containsKey(charset.name()) || | boolean isUnicode = ENCODINGS.containsKey(charset.name()) || | |||
"UTF-16".equals(charset.name()) || | "UTF-16".equals(charset.name()) || | |||
"UTF-32".equals(charset.name()); | "UTF-32".equals(charset.name()); | |||
try { | try { | |||
InputStream inputStream = StreamUtils.nonClosing(inputMes sage.getBody()); | InputStream inputStream = StreamUtils.nonClosing(inputMes sage.getBody()); | |||
if (inputMessage instanceof MappingJacksonInputMessage) { | if (inputMessage instanceof MappingJacksonInputMessage) { | |||
Class<?> deserializationView = ((MappingJacksonIn putMessage) inputMessage).getDeserializationView(); | Class<?> deserializationView = ((MappingJacksonIn putMessage) inputMessage).getDeserializationView(); | |||
if (deserializationView != null) { | if (deserializationView != null) { | |||
ObjectReader objectReader = objectMapper. readerWithView(deserializationView).forType(javaType); | ObjectReader objectReader = objectMapper. readerWithView(deserializationView).forType(javaType); | |||
skipping to change at line 417 | skipping to change at line 417 | |||
@Override | @Override | |||
protected void writeInternal(Object object, @Nullable Type type, HttpOutp utMessage outputMessage) | protected void writeInternal(Object object, @Nullable Type type, HttpOutp utMessage outputMessage) | |||
throws IOException, HttpMessageNotWritableException { | throws IOException, HttpMessageNotWritableException { | |||
MediaType contentType = outputMessage.getHeaders().getContentType (); | MediaType contentType = outputMessage.getHeaders().getContentType (); | |||
JsonEncoding encoding = getJsonEncoding(contentType); | JsonEncoding encoding = getJsonEncoding(contentType); | |||
Class<?> clazz = (object instanceof MappingJacksonValue ? | Class<?> clazz = (object instanceof MappingJacksonValue ? | |||
((MappingJacksonValue) object).getValue().getClas s() : object.getClass()); | ((MappingJacksonValue) object).getValue().getClas s() : object.getClass()); | |||
ObjectMapper objectMapper = selectObjectMapper(clazz, contentType ); | ObjectMapper objectMapper = selectObjectMapper(clazz, contentType ); | |||
Assert.state(objectMapper != null, "No ObjectMapper for " + clazz .getName()); | Assert.state(objectMapper != null, () -> "No ObjectMapper for " + clazz.getName()); | |||
OutputStream outputStream = StreamUtils.nonClosing(outputMessage. getBody()); | OutputStream outputStream = StreamUtils.nonClosing(outputMessage. getBody()); | |||
try (JsonGenerator generator = objectMapper.getFactory().createGe nerator(outputStream, encoding)) { | try (JsonGenerator generator = objectMapper.getFactory().createGe nerator(outputStream, encoding)) { | |||
writePrefix(generator, object); | writePrefix(generator, object); | |||
Object value = object; | Object value = object; | |||
Class<?> serializationView = null; | Class<?> serializationView = null; | |||
FilterProvider filters = null; | FilterProvider filters = null; | |||
JavaType javaType = null; | JavaType javaType = null; | |||
End of changes. 2 change blocks. | ||||
2 lines changed or deleted | 2 lines changed or added |