Prevent using NestedEntitySerializer if target serializer does not support unwrapping.
We now verify that the serializer registered for the type that's supposed to be handled by the NestedEntitySerializer actually supports unwrapping as the serialization in EntityModel (MapSuppressingUnwrappingSerializer) requires that to work properly. Fixes #2056.
This commit is contained in:
@@ -406,6 +406,12 @@ public class PersistentEntityJackson2Module extends SimpleModule {
|
||||
return value;
|
||||
}
|
||||
|
||||
JsonSerializer<Object> unwrappingSerializer = serializer.unwrappingSerializer(NameTransformer.NOP);
|
||||
|
||||
if (!unwrappingSerializer.isUnwrappingSerializer()) {
|
||||
return value;
|
||||
}
|
||||
|
||||
PersistentEntity<?, ?> entity = entities.getRequiredPersistentEntity(value.getClass());
|
||||
|
||||
return invoker.invokeProcessorsFor(PersistentEntityResource.build(value, entity).//
|
||||
|
||||
Reference in New Issue
Block a user