From 4294e9ec9aaf0a4eec276b7af7d22e96ced99053 Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Fri, 19 Jun 2015 17:01:24 +0200 Subject: [PATCH] DATAREST-588 - Tweak ResourceSupportHttpMessageConverter to really reject all non-configured types. We now override canRead(Type, Class, MediaType) and tweak some of the delegate to reflect the patch in Spring HATEOAS spring-hateoas/#360 but without having to upgrade to the new version. --- .../webmvc/config/RepositoryRestMvcConfiguration.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java index 214334e10..10496025c 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.java @@ -15,6 +15,7 @@ */ package org.springframework.data.rest.webmvc.config; +import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -730,6 +731,16 @@ public class RepositoryRestMvcConfiguration extends HateoasAwareSpringDataWebCon this.order = order; } + /* + * (non-Javadoc) + * @see org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter#canRead(java.lang.reflect.Type, java.lang.Class, org.springframework.http.MediaType) + */ + @Override + public boolean canRead(Type type, Class contextClass, MediaType mediaType) { + return ResourceSupport.class.isAssignableFrom(getJavaType(type, contextClass).getRawClass()) + && super.canRead(type, contextClass, mediaType); + } + /* * (non-Javadoc) * @see org.springframework.core.Ordered#getOrder()