Hi!
When using PATCH for objects that use @JsonAnySetter for deserialization and therefore don't have a corresponding property in MappedProperties, DomainObjectReader#doMerge fails. This used to work in previous versions of this class, when
if (!mappedProperties.hasPersistentPropertyForField(fieldName))
was used (without removing the field from deserialization, see changes in commit and commit ). Now
if (!mappedProperties.isWritableProperty(fieldName)) {
checks whether the property is writable (which is an improvement). But this also returns true if the class to merge contains an @JsonAnySetter. This means that the following call
PersistentProperty<?> property = mappedProperties.getPersistentProperty(fieldName);
returns null and the call after this
Optional<Object> rawValue = Optional.ofNullable(accessor.getProperty(property));
Throws the error.
The solution IMHO is a simple null check before the accessor.getProperty call like
if (property == null) {
continue;
}
This lets @JsonAnySetter handle the further deserialization, as I understand was the intention in previous versions and should be now.
I confirmed this fix with a test case, see referenced pull request.
Hi!
When using
PATCHfor objects that use@JsonAnySetterfor deserialization and therefore don't have a corresponding property inMappedProperties,DomainObjectReader#doMergefails. This used to work in previous versions of this class, whenwas used (without removing the field from deserialization, see changes in commit and commit ). Now
checks whether the property is writable (which is an improvement). But this also returns
trueif the class to merge contains an@JsonAnySetter. This means that the following callreturns
nulland the call after thisThrows the error.
The solution IMHO is a simple null check before the
accessor.getPropertycall likeThis lets
@JsonAnySetterhandle the further deserialization, as I understand was the intention in previous versions and should be now.I confirmed this fix with a test case, see referenced pull request.