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

DomainObjectReader throws UnsupportedOperationException on PATCH request when altering the size of existing Array [DATAREST-1068] #1433

Closed
spring-projects-issues opened this issue May 5, 2017 · 2 comments

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented May 5, 2017

Ricardo Estrada opened DATAREST-1068 and commented

When sending a PATCH request with some fields to update an existing entity, if one of the fields is an array, and the size of the array is different from the existing property array, handleArrayNode method from DomainObjectReader class throws an UnsupportedOperationException.

Package: org.springframework.data.rest.webmvc.json
Class name: DomainObjectReader

When debugging all the way down into DomainObjectReader class, the handleArrayNode method seems to be called from handleArray method, which is sending a Collection as parameter after calling ifCollection(source) method. This ifCollection method is returning a fixed size List (from Arrays.asList) which eventually, handleArrayNode method is trying to alter in size with .add or .remove methods on the given Collection, and here is where the UnsupportedOperationException is thrown.

I am using Spring Boot 1.5.2-RELEASE. But i see no changes in Spring Data Rest repository on these methods class for latest branches/tags


Affects: 2.6.1 (Ingalls SR1)

Referenced from: pull request #371

Backported to: 3.2.5 (Moore SR5), 3.1.16 (Lovelace SR16)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 16, 2020

mdfrostt commented

DomainObjectReader still contains this flaw as of today's build of version 3.3.0.BUILD-SNAPSHOT. I have created a a unit test that demonstrates the problem and the code to fix it. But I have no clue how to create a branch on which to submit a PR. I'd be happy to upload what I have if someone could assist with the branch permissions

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Feb 19, 2020

mdfrostt commented

PR 371 has been submitted

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