JaxRsHandler.localRequest.remove();
} catch (Exception ex) {
try {
BodyStoringResponse responseFake = new BodyStoringResponse(response);
JaxRsHandler.handleException(ex, request, responseFake);
final MessageBody body = responseFake.getBody();
if (body != null) {
try {
//doing priviledged as this might invoke doAs to
//write the body as subject
AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
@Override
public Subject run() throws IOException {
body.writeTo(out);
return null;
}
});
} catch (PrivilegedActionException privEx) {
Throwable cause = privEx.getCause();