spring-projects / spring-projects/spring-data-rest

DATAREST-1383 causes top level properties with @JsonSetter to be missed. [DATAREST-1573]

Open
#1,911 3 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Joseph Valerio opened DATAREST-1573 and commented

We just upgraded to SpringBoot 2.3.2.

We are using spring datarest 3.3.2 with JPA against a RDBMS

We use a PATCH to update our user's passwords.  We have a setter on our User Object setPassword() annotated with @JsonSetter, but there is no corresponding persisted property.  This method is used to set the persisted encryptedPassword property on the user.  The following commit on DomainObjectReader causes this to no longer work:

https://github.com/spring-projects/spring-data-rest/commit/c616c539052ad30c5dcc7a7acf8076f2f993d513

229:       if (!mappedProperties.hasPersistentPropertyForField(fieldName)) {				 
230:           i.remove();
231:           continue;
232:       }

The i.remove on line 230 removes the password property from consideration since it is not a PersistentProperty  

If this property is not removed, it will cause the setter to be invoked at line 285:

 

return mapper.readerForUpdating(target).readValue(root);

 

If we change the Method to a PUT this works correctly, but it should also work for patch.

If you are not following my explaination, I can create a test project to expose the issue on request


1 votes, 2 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.