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

NPE when updating resource via PUT [DATAREST-701] #1072

Closed
spring-projects-issues opened this issue Nov 9, 2015 · 4 comments
Closed

NPE when updating resource via PUT [DATAREST-701] #1072

spring-projects-issues opened this issue Nov 9, 2015 · 4 comments
Assignees
Labels
type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Nov 9, 2015

Justin Lewis Salmon opened DATAREST-701 and commented

I'm not sure if this is a regression, but it is basically the same issue as DATAREST-491 and DATAREST-605. I'm seeing this using spring-boot-starter-data-rest:1.3.0.M5.

Check out the demo project and do the following to reproduce:

Create a resource:

curl -v -X POST http://localhost:8080/tickets -H "Content-Type: application/json" -d '{"properties" : {"a": "1", "b": {"c": "2"}}}'

Try to update the properties of the resource via PUT:

curl -v -X PUT http://localhost:8080/tickets/5640c0b6b760828633d03cca -H "Content-Type: application/json" -d '{"properties" : {"a": "3", "b": {"c": "4"}}}'

The following NPE is observed:

org.springframework.http.converter.HttpMessageNotReadableException: Could not read an object of type class demo.Ticket from the request!; nested exception is org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException
	at org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate(PersistentEntityResourceHandlerMethodArgumentResolver.java:206) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	...
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-8.0.28.jar:8.0.28]
	at java.lang.Thread.run(Thread.java:745) [na:1.8.0_25]
Caused by: org.springframework.http.converter.HttpMessageNotReadableException: Could not read payload!; nested exception is java.lang.NullPointerException
	at org.springframework.data.rest.webmvc.json.DomainObjectReader.merge(DomainObjectReader.java:138) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.DomainObjectReader.readPut(DomainObjectReader.java:130) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.config.JsonPatchHandler.applyPut(JsonPatchHandler.java:134) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.config.PersistentEntityResourceHandlerMethodArgumentResolver.readPutForUpdate(PersistentEntityResourceHandlerMethodArgumentResolver.java:203) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	... 52 common frames omitted
Caused by: java.lang.NullPointerException: null
	at org.springframework.data.rest.webmvc.json.DomainObjectReader.getJacksonProperties(DomainObjectReader.java:254) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMerge(DomainObjectReader.java:158) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMergeNestedMap(DomainObjectReader.java:238) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.DomainObjectReader.doMerge(DomainObjectReader.java:196) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	at org.springframework.data.rest.webmvc.json.DomainObjectReader.merge(DomainObjectReader.java:136) ~[spring-data-rest-webmvc-2.4.0.RELEASE.jar:na]
	... 55 common frames omitted

Affects: 2.4 GA (Gosling)

Backported to: 2.4.1 (Gosling SR1), 2.3.3 (Fowler SR3)

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 9, 2015

Oliver Drotbohm commented

Thanks for filing that one Justin. As you already have a sample project in place, would you mind adding a test case that executes the requests so that we have something easily repeatable?

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 9, 2015

Oliver Drotbohm commented

Nevermind, I got it reproduced in a small test case :).

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 9, 2015

Justin Lewis Salmon commented

Ok, great, I won't update my project then. As always, thanks for the swift response Oliver!

@spring-projects-issues
Copy link
Author

@spring-projects-issues spring-projects-issues commented Nov 10, 2015

Oliver Drotbohm commented

This should be fixed in master and the bugfix branches for Fowler and Gosling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug
Projects
None yet
Development

No branches or pull requests

2 participants