From df239e49ce6cd237578c55404652b20c37db269e Mon Sep 17 00:00:00 2001 From: Jon Brisbin Date: Tue, 12 Mar 2013 09:49:07 -0500 Subject: [PATCH] Catch an error condition. --- .../json/PersistentEntityJackson2Module.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/spring-data-rest-repository/src/main/java/org/springframework/data/rest/repository/json/PersistentEntityJackson2Module.java b/spring-data-rest-repository/src/main/java/org/springframework/data/rest/repository/json/PersistentEntityJackson2Module.java index ba8985f50..f3ae92ab9 100644 --- a/spring-data-rest-repository/src/main/java/org/springframework/data/rest/repository/json/PersistentEntityJackson2Module.java +++ b/spring-data-rest-repository/src/main/java/org/springframework/data/rest/repository/json/PersistentEntityJackson2Module.java @@ -109,7 +109,14 @@ public class PersistentEntityJackson2Module extends SimpleModule implements Init @SuppressWarnings({"unchecked"}) @Override public void afterPropertiesSet() throws Exception { for(Class domainType : repositories) { - addDeserializer(domainType, new ResourceDeserializer(repositories.getPersistentEntity(domainType))); + PersistentEntity pe = repositories.getPersistentEntity(domainType); + if(null == pe) { + if(LOG.isWarnEnabled()) { + LOG.warn("The domain class {} does not have PersistentEntity metadata.", domainType.getName()); + } + } else { + addDeserializer(domainType, new ResourceDeserializer(pe)); + } } } @@ -141,6 +148,7 @@ public class PersistentEntityJackson2Module extends SimpleModule implements Init if(uriDomainClassConverter.matches(URI_TYPE, entityType)) { entity = uriDomainClassConverter.convert(uri, URI_TYPE, entityType); } + continue; }