Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PUT nulls Json read-only property [DATAREST-1006] #1369

Closed
spring-projects-issues opened this issue Feb 10, 2017 · 10 comments
Closed

PUT nulls Json read-only property [DATAREST-1006] #1369

spring-projects-issues opened this issue Feb 10, 2017 · 10 comments
Assignees

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Feb 10, 2017

Mathias D opened DATAREST-1006 and commented

Moving to spring data rest Ingalls GA introduces a new problem regarding read only json properties.

We use @JsonProperty(access = READ_ONLY) to mark fields as read-only in our entities. So this field should be serialized but not deserialized.

With Ingalls a PUT request nulls such a property.

I think in a PUT should treat @JsonProperty(access = READ_ONLY) just as @JsonIgnore - so such properts is just ignored in a PUT.

I have added a test on my fork to reproduce the case: mduesterhoeft@c46df6e


Affects: 2.6 GA (Ingalls)

Backported to: 3.0.1 (Kay SR1), 2.6.8 (Ingalls SR8)

1 votes, 3 watchers

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 10, 2017

Mathias D commented

This issue is related to FasterXML/jackson-databind#935

This is fixed with jackson-databind 2.8.7-SNAPSHOT (2.8.7 not yet released)

Still I had to add handling of ignored fields to MappedProperties to make it work.

It seems that fields annotated with @JsonIgnore do not show up in BeanDescription.findProperties. A field annotated with @JsonProperty(access = READ_ONLY) does but at the same time it is contained in BeanDescription.getIgnoredPropertyNames

I added another branch to show the solution that can be applied once jackson-databind 2.8.7 is released and spring-data-rest references it.

mduesterhoeft@61ee267

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 10, 2017

Mathias D commented

A workaround that solved it for me is using @ReadOnlyProperty

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Michael S commented

Any news on this? The fix provided in Mathias D's comment (and PR) looks promising

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Mathias D commented

Just saw that we have Jackson 2.8.8 now. I will update my PR accordingly

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Oliver Drotbohm commented

Is there any fix needed at all? You original comment implied it would be fixed with a plain Jackson upgrade, which is why I was basically waiting for its release. Happy to look into what's needed to be done in case there is something

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Mathias D commented

I had to skip ignored properties in MappedProperties to get it to work

Please see my commit - it contains a test to reproduce the issue.
mduesterhoeft@61ee267

The test is still red on the current master

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Oliver Drotbohm commented

I'll have a look, thanks

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Mathias D commented

Just updated the PR #258

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Oliver Drotbohm commented

That's merged. Feel free to give the snapshots a try

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Oct 4, 2017

Michael S commented

Thanks guys. I stumbled upon a related, but different bug that lets PATCH requests override read-only properties just today: DATAREST-1144

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants