With 0.8.0-rc2, given a resource
@Path("/foo")
@Consumes(MediaType.APPLICATION_JSON)
class MyResource
{
@Path("{id}")
public Response put(@PathParam("id") long id, @NotNull @Valid RequestBody body) { ... }
}
I"m not getting the kinds of error messages I would hope to see on requests that don't contain any entity content.
If I submit:
PUT /foo/84 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Content-Length: 0
I don't get any error at all, unless I add a null pointer check in my resource's put method. Tracing the code, the JacksonMessageBodyProvider is never asked to validate the content. I would expect Jersey to complain that the content-type doesn't match the method.
If I submit:
PUT /org/84 HTTP/1.1
Accept: */*
Accept-Encoding: gzip, deflate
Content-Length: 0
Content-Type: application/json
Then the JacksonMessageBodyProvider *is* called, but I don't get any meaningful errors:
TTP/1.1 422
Content-Length: 13
Content-Type: application/json
Date: Mon, 02 Feb 2015 19:25:01 GMT
{
"errors": []
}
422 seems an odd choice here, as well, which is supposed to be for cases where the syntax is correct, but the content can't be understood.
Is there a straightforward way to ensure I get a 400 error for this use case?