@Test void failure() throws Exception { final AggregatedHttpResponse res = handler.authFailed(delegate, ctx, req, new Exception("oops")) .aggregate().join(); assertThat(res.status()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR); assertThat(res.contentType()).isEqualTo(MediaType.JSON_UTF_8); assertThatJson(res.contentUtf8()).isEqualTo( '{' + " \"exception\": \"java.lang.Exception\"," + " \"message\":\"oops\"" + '}'); }
@Override public HttpResponse authFailed(HttpService delegate, ServiceRequestContext ctx, HttpRequest req, @Nullable Throwable cause) throws Exception { if (cause != null) { if (!(cause instanceof ShuttingDownException)) { logger.warn("Unexpected exception during authorization:", cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.INTERNAL_SERVER_ERROR, cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.UNAUTHORIZED, AUTHORIZATION_EXCEPTION); }
CentralDogmaAuthFailureHandler implements AuthFailureHandler { @Override public HttpResponse authFailed(HttpService delegate, ServiceRequestContext ctx, HttpRequest req, @Nullable Throwable cause) throws Exception { if (cause != null) { if (!(cause instanceof ShuttingDownException)) { logger.warn("Unexpected exception during authorization:", cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.INTERNAL_SERVER_ERROR, cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.UNAUTHORIZED, AUTHORIZATION_EXCEPTION); } }
CentralDogmaAuthFailureHandler implements AuthFailureHandler { @Override public HttpResponse authFailed(HttpService delegate, ServiceRequestContext ctx, HttpRequest req, @Nullable Throwable cause) throws Exception { if (cause != null) { if (!(cause instanceof ShuttingDownException)) { logger.warn("Unexpected exception during authorization:", cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.INTERNAL_SERVER_ERROR, cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.UNAUTHORIZED, AUTHORIZATION_EXCEPTION); }  }
CentralDogmaAuthFailureHandler implements AuthFailureHandler { @Override public HttpResponse authFailed(HttpService delegate, ServiceRequestContext ctx, HttpRequest req, @Nullable Throwable cause) throws Exception { if (cause != null) { if (!(cause instanceof ShuttingDownException)) { logger.warn("Unexpected exception during authorization:", cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.INTERNAL_SERVER_ERROR, cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.UNAUTHORIZED, AUTHORIZATION_EXCEPTION); }  @Override HttpResponse authFailed(HttpService delegate,
                                   ServiceRequestContext ctx, HttpRequest req,
                                   @Nullable Throwable cause); }
CentralDogmaAuthFailureHandler implements AuthFailureHandler { @Override public HttpResponse authFailed(HttpService delegate, ServiceRequestContext ctx, HttpRequest req, @Nullable Throwable cause) throws Exception { if (cause != null) { if (!(cause instanceof ShuttingDownException)) { logger.warn("Unexpected exception during authorization:", cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.INTERNAL_SERVER_ERROR, cause); } return HttpApiUtil.newResponse(ctx, HttpStatus.UNAUTHORIZED, AUTHORIZATION_EXCEPTION); }  @Override HttpResponse authFailed(HttpService delegate,
                                   ServiceRequestContext ctx, HttpRequest req,
                                   @Nullable Throwable cause);  }