Skip to content

Commit

Permalink
AbstractJackson2HttpMessageConverter's canRead/canWrite checks media …
Browse files Browse the repository at this point in the history
…type first before delegating to Jackson

Issue: SPR-14163
(cherry picked from commit e366746)
  • Loading branch information
jhoeller committed Apr 13, 2016
1 parent 863bae7 commit bf3cadb
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,14 @@ public boolean canRead(Class<?> clazz, MediaType mediaType) {
@Override
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
JavaType javaType = getJavaType(type, contextClass);
if (!canRead(mediaType)) {
return false;
}
if (!jackson23Available || !logger.isWarnEnabled()) {
return (this.objectMapper.canDeserialize(javaType) && canRead(mediaType));
return this.objectMapper.canDeserialize(javaType);
}
AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
if (this.objectMapper.canDeserialize(javaType, causeRef) && canRead(mediaType)) {
if (this.objectMapper.canDeserialize(javaType, causeRef)) {
return true;
}
Throwable cause = causeRef.get();
Expand All @@ -167,11 +170,14 @@ public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {

@Override
public boolean canWrite(Class<?> clazz, MediaType mediaType) {
if (!canWrite(mediaType)) {
return false;
}
if (!jackson23Available || !logger.isWarnEnabled()) {
return (this.objectMapper.canSerialize(clazz) && canWrite(mediaType));
return this.objectMapper.canSerialize(clazz);
}
AtomicReference<Throwable> causeRef = new AtomicReference<Throwable>();
if (this.objectMapper.canSerialize(clazz, causeRef) && canWrite(mediaType)) {
if (this.objectMapper.canSerialize(clazz, causeRef)) {
return true;
}
Throwable cause = causeRef.get();
Expand Down

0 comments on commit bf3cadb

Please sign in to comment.