@Override
  public void handleRestRequest(RestRequest req, Map<String, String> wireAttrs, RequestContext requestContext,
      TransportCallback<RestResponse> callback)
  {
    _transportDispatcher.handleRestRequest(req, wireAttrs, requestContext,
        new RequestFinalizerTransportCallback<>(callback, requestContext, req));
  }
@Test
  public void testExistingRequestFinalizerManager()
  {
    when(_restTransportResponse.getResponse())
        .thenReturn(_restResponse);

    final RequestContext requestContext = new RequestContext();
    final RequestFinalizerManagerImpl manager = new RequestFinalizerManagerImpl(null, requestContext);

    final AtomicBoolean atomicBoolean = new AtomicBoolean(false);
    manager.registerRequestFinalizer((request, response ,requestContext1, throwable) -> atomicBoolean.set(true));

    requestContext.putLocalAttr(R2Constants.SERVER_REQUEST_FINALIZER_MANAGER_REQUEST_CONTEXT_KEY, manager);

    final TestTransportCallback<RestResponse> transportCallback = new TestTransportCallback<>(false);
    _outerDispatcher.handleRestRequest(null, null, requestContext, transportCallback);

    Assert.assertEquals(_outerDispatcher._executionOrder, 1);
    Assert.assertEquals(_innerDispatcher._executionOrder, 2);
    Assert.assertEquals(_innerDispatcher._transportCallback._executionOrder, 3);
    Assert.assertEquals(_outerDispatcher._transportCallback._executionOrder, 4);
    Assert.assertEquals(transportCallback._executionOrder, 5);
    Assert.assertEquals(_requestFinalizer._executionOrder, 6, "Expected request to be finalized after the callback.");
    Assert.assertTrue(atomicBoolean.get(), "Expected the request finalizer registered before reaching the"
        + "RequestFinalizerDispatcher to still be invoked.");
  }