-
Notifications
You must be signed in to change notification settings - Fork 563
Description
This piece of code to get the affordances may result in a NullPointerException in case body is null.
Lines 77 to 78 in 3eed1c2
| boolean hasAffordances = body.getLinks().stream() | |
| .anyMatch(it -> !it.getAffordances().isEmpty()); |
In the ResponseBodyAdvice interface from spring-webmvc, the body parameter is annotated as @Nullable, an annotation that was not taken into account in HalFormsAdaptingResponseBodyAdvice.
While developing a spring-data-rest application, I encountered a case where the body might be null, in the case that a 304 Not Modified response is being sent.
A Not Modified status can be sent by spring-data-rest when there is an entity with a @LastModifiedDate-annotated property, and an If-Modified-Since request header is sent by the client.
In case the date from If-Modified-Since is after the date from the @LastModifiedDate property, the 304 Not Modified response is sent with a null body, resulting in a NullPointerException from HalFormsAdaptingResponseBodyAdvice, which always results in an Internal Server Error.