From 2a835c48fac5b71d60cabf2cef0da9615eae2aeb Mon Sep 17 00:00:00 2001 From: Oliver Gierke Date: Tue, 8 Sep 2015 15:14:28 +0200 Subject: [PATCH] DATAREST-665 - Prevent non-serializable properties from making it into the schema. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We now explicitly skip non-Jackson-serializable properties from being rendered in the schema. This prevents exceptions in rare cases where the Jackson BeanPropertyDefinition is only backed by a setter. The issue occurred with current Spring Data Gemfire as it considers a BigDecimal a PersistentEntity and then failed to produce a proper ResolvableProperty for setScale(…) as it's a setter-only property. Related tickets: SGF-429. --- .../webmvc/json/PersistentEntityToJsonSchemaConverter.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverter.java b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverter.java index e8083e57a..f51b7b120 100644 --- a/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverter.java +++ b/spring-data-rest-webmvc/src/main/java/org/springframework/data/rest/webmvc/json/PersistentEntityToJsonSchemaConverter.java @@ -166,8 +166,6 @@ public class PersistentEntityToJsonSchemaConverter implements ConditionalGeneric JsonSchemaPropertyRegistrar registrar = new JsonSchemaPropertyRegistrar(jackson); - // final List> properties = new ArrayList>(); - for (BeanPropertyDefinition definition : jackson) { PersistentProperty persistentProperty = entity.getPersistentProperty(definition.getInternalName()); @@ -182,6 +180,10 @@ public class PersistentEntityToJsonSchemaConverter implements ConditionalGeneric if (persistentProperty.isVersionProperty()) { continue; } + + if (!definition.couldSerialize()) { + continue; + } } TypeInformation propertyType = persistentProperty == null