#360 - Improved TypeConstrainedHttpMessageConverter on generics matching.

We now locally resolve the generic type using Jackson's JavaType in canRead(Type, Class, MediaType) to avoid having to call the non-generic method as this caused us having to tweak it's implementation to avoid the super.canRead(Class, MediaType) check as this in turn forwards to the generic method (which then would've caused a stack overflow.
This commit is contained in:
Oliver Gierke
2015-06-24 17:22:02 +02:00
parent 28234e16a5
commit ab613f85ac

View File

@@ -51,7 +51,7 @@ public class TypeConstrainedMappingJackson2HttpMessageConverter extends MappingJ
*/
@Override
public boolean canRead(Class<?> clazz, MediaType mediaType) {
return type.isAssignableFrom(clazz) && super.canRead(mediaType);
return type.isAssignableFrom(clazz) && super.canRead(clazz, mediaType);
}
/*
@@ -60,12 +60,8 @@ public class TypeConstrainedMappingJackson2HttpMessageConverter extends MappingJ
*/
@Override
public boolean canRead(Type type, Class<?> contextClass, MediaType mediaType) {
if (type instanceof Class) {
return canRead((Class<?>) type, mediaType);
}
return super.canRead(type, contextClass, mediaType);
return this.type.isAssignableFrom(getJavaType(type, contextClass).getRawClass())
&& super.canRead(type, contextClass, mediaType);
}
/*