crnk-project / crnk-framework

JSON API library for Java
Apache License 2.0
287 stars 156 forks source link

RelationshipsPatchController throws a NullPointerException #804

Open datagitlies opened 3 years ago

datagitlies commented 3 years ago

Sending a specific PATCH request to a relationship link can cause the RelationshipsPatchController to throw a NullPointerException.

version: 3.3.20200920055408

example request:

PATCH /articles/1/relationships/comments
Content-Type: application/vnd.api+json
Accept: */*
Host: localhost:8080
content-length: 13
{"data":null}

example response:

HTTP/1.1 500
status: 500
Content-Type: application/vnd.api+json
Content-Length: 61
{"errors":[{"status":"500","title":"INTERNAL_SERVER_ERROR"}]}

example stack trace:

java.lang.NullPointerException: null
at io.crnk.core.engine.internal.dispatcher.controller.RelationshipsPatchController.lambda$processToManyRelationship$0(RelationshipsPatchController.java:43)
at io.crnk.core.engine.result.ImmediateResult.merge(ImmediateResult.java:50)
at io.crnk.core.engine.internal.dispatcher.controller.RelationshipsPatchController.processToManyRelationship(RelationshipsPatchController.java:30)
at io.crnk.core.engine.internal.dispatcher.controller.RelationshipsResourceUpsert.handleAsync(RelationshipsResourceUpsert.java:100)
at io.crnk.core.engine.internal.dispatcher.controller.BaseController.handle(BaseController.java:56)
at io.crnk.core.engine.internal.http.DocumentFilterChainImpl.doFilter(DocumentFilterChainImpl.java:28)
at io.crnk.core.engine.internal.http.JsonApiRequestProcessor.processAsync(JsonApiRequestProcessor.java:167)
at io.crnk.core.engine.internal.http.JsonApiRequestProcessor.processAsync(JsonApiRequestProcessor.java:131)
at io.crnk.core.engine.internal.http.HttpRequestDispatcherImpl.process(HttpRequestDispatcherImpl.java:73)
at io.crnk.servlet.CrnkFilter.doFilter(CrnkFilter.java:85)