Hello,
A couple of days ago I ran into a problem with throwing WebApplication examples with a response object:
throw new WebApplicationException(Response.status(412)
.type("text/plain;charset=utf-8")
.entity("Something went wrong").build());
Throwing this exception would give a text/plain body with the entity body but with http code 200. Throwing the same exception without an entity would give the expected (412 response with an empty body).
After a little code browsing I found the problem in Dispatcher.java invoke method. I created a patch file from revision 133 attached to this email.
Regards,
Thomas Cremers
Index: Dispatcher.java
===================================================================
— Dispatcher.java (revision 135)
+++ Dispatcher.java (working copy)
@@ -136,6 +136,7 @@
if (jaxrsResponse.getEntity() != null)
{ + response.setStatus(jaxrsResponse.getStatus()); MediaType responseContentType = resolveContentType(invoker, in, jaxrsResponse); writeResponse(response, invoker, jaxrsResponse.getEntity(), responseContentType); }