MatchRequestReceiver extends RequestReceiver<MatchController> { @Override public void receive(HttpReceiverContext ctx) { boolean unhandledException = true; try { Timer.Context timerContext = requestTimer().time(); @SuppressWarnings("unchecked") MatchRequest request = newRequest(ctx.httpRequest()).build(); @SuppressWarnings("unchecked") MatchResponse response = newResponse(request, ctx.httpResponse()).build(); controller().onRequest(request, response); successResponseMeter().mark(); timerContext.close(); unhandledException = false; } catch (InterceptorAbortException e) { ctx.httpResponse().setStatusOk(); logger.error("InterceptorAbortException thrown", e); interceptorAbortMeter().mark(); } finally { if (unhandledException) { interceptorOtherMeter().mark(); } } } @Inject  MatchRequestReceiver(
      Exchange exchange,
      MetricRegistry metricRegistry,
      MatchController controller); @Override void receive(HttpReceiverContext ctx);  }
@Test public void testReceiver() { MetricRegistry metricRegistry = new MetricRegistry(); MatchController controller = MatchTestUtil.newMatchController( metricRegistry, new SimpleMatchInterceptor()); TestReceiver receiver = new TestReceiver(metricRegistry, controller); receiver.receive(new DefaultHttpReceiverContext( DEFAULT_REQUEST, StandardHttpResponse.newBuilder())); controller.stopAsync().awaitTerminated(); }
@Test public void testHttpInterceptorAbortException() { MetricRegistry metricRegistry = new MetricRegistry(); MatchController controller = MatchTestUtil.newMatchController( metricRegistry, new MatchInterceptor() { @Override public void execute( InterceptorChain<MatchRequest, MatchResponse> chain) { throw new InterceptorAbortException("It's Friday, too tired to work"); }}); TestReceiver receiver = new TestReceiver(metricRegistry, controller); receiver.receive(new DefaultHttpReceiverContext( DEFAULT_REQUEST, StandardHttpResponse.newBuilder())); controller.stopAsync().awaitTerminated(); }