Always invoke Jackson serialization with AtomicReference cause
Issue: SPR-15760
This commit is contained in:
parent
8359201a0d
commit
5f767a86f5
|
@ -146,9 +146,6 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
|
|||
return false;
|
||||
}
|
||||
JavaType javaType = this.objectMapper.constructType(targetClass);
|
||||
if (!logger.isWarnEnabled()) {
|
||||
return this.objectMapper.canDeserialize(javaType);
|
||||
}
|
||||
AtomicReference<Throwable> causeRef = new AtomicReference<>();
|
||||
if (this.objectMapper.canDeserialize(javaType, causeRef)) {
|
||||
return true;
|
||||
|
@ -162,9 +159,6 @@ public class MappingJackson2MessageConverter extends AbstractMessageConverter {
|
|||
if (!supportsMimeType(headers)) {
|
||||
return false;
|
||||
}
|
||||
if (!logger.isWarnEnabled()) {
|
||||
return this.objectMapper.canSerialize(payload.getClass());
|
||||
}
|
||||
AtomicReference<Throwable> causeRef = new AtomicReference<>();
|
||||
if (this.objectMapper.canSerialize(payload.getClass(), causeRef)) {
|
||||
return true;
|
||||
|
|
|
@ -20,6 +20,8 @@ import java.io.IOException;
|
|||
import java.lang.reflect.Type;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonEncoding;
|
||||
|
@ -79,20 +81,6 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
|||
|
||||
|
||||
protected AbstractJackson2HttpMessageConverter(ObjectMapper objectMapper) {
|
||||
init(objectMapper);
|
||||
}
|
||||
|
||||
protected AbstractJackson2HttpMessageConverter(ObjectMapper objectMapper, MediaType supportedMediaType) {
|
||||
super(supportedMediaType);
|
||||
init(objectMapper);
|
||||
}
|
||||
|
||||
protected AbstractJackson2HttpMessageConverter(ObjectMapper objectMapper, MediaType... supportedMediaTypes) {
|
||||
super(supportedMediaTypes);
|
||||
init(objectMapper);
|
||||
}
|
||||
|
||||
protected void init(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
setDefaultCharset(DEFAULT_CHARSET);
|
||||
DefaultPrettyPrinter prettyPrinter = new DefaultPrettyPrinter();
|
||||
|
@ -100,6 +88,16 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
|||
this.ssePrettyPrinter = prettyPrinter;
|
||||
}
|
||||
|
||||
protected AbstractJackson2HttpMessageConverter(ObjectMapper objectMapper, MediaType supportedMediaType) {
|
||||
this(objectMapper);
|
||||
setSupportedMediaTypes(Collections.singletonList(supportedMediaType));
|
||||
}
|
||||
|
||||
protected AbstractJackson2HttpMessageConverter(ObjectMapper objectMapper, MediaType... supportedMediaTypes) {
|
||||
this(objectMapper);
|
||||
setSupportedMediaTypes(Arrays.asList(supportedMediaTypes));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set the {@code ObjectMapper} for this view.
|
||||
|
@ -158,9 +156,6 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
|||
return false;
|
||||
}
|
||||
JavaType javaType = getJavaType(type, contextClass);
|
||||
if (!logger.isWarnEnabled()) {
|
||||
return this.objectMapper.canDeserialize(javaType);
|
||||
}
|
||||
AtomicReference<Throwable> causeRef = new AtomicReference<>();
|
||||
if (this.objectMapper.canDeserialize(javaType, causeRef)) {
|
||||
return true;
|
||||
|
@ -174,9 +169,6 @@ public abstract class AbstractJackson2HttpMessageConverter extends AbstractGener
|
|||
if (!canWrite(mediaType)) {
|
||||
return false;
|
||||
}
|
||||
if (!logger.isWarnEnabled()) {
|
||||
return this.objectMapper.canSerialize(clazz);
|
||||
}
|
||||
AtomicReference<Throwable> causeRef = new AtomicReference<>();
|
||||
if (this.objectMapper.canSerialize(clazz, causeRef)) {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue