@Test
  public void badResponseHandlerAndRestRequestTest() throws Exception {
    // What happens inside FrontendRestRequestService during this test?
    // 1. Since the RestRequest throws errors, FrontendRestRequestService will attempt to submit response with exception
    //      to FrontendTestResponseHandler.
    // 2. The submission will fail because FrontendTestResponseHandler has been shutdown.
    // 3. FrontendRestRequestService will directly complete the request over the RestResponseChannel with the *original*
    //      exception.
    // 4. It will then try to release resources but closing the RestRequest will also throw an exception. This exception
    //      is swallowed.
    // What the test is looking for -> No exceptions thrown when the handle is run and the original exception arrives
    // safely.
    responseHandler.shutdown();
    for (String methodName : new String[]{"handleGet", "handlePost", "handleHead", "handleDelete", "handleOptions", "handlePut"}) {
      Method method =
          FrontendRestRequestService.class.getDeclaredMethod(methodName, RestRequest.class, RestResponseChannel.class);
      responseHandler.reset();
      RestRequest restRequest = new BadRestRequest();
      MockRestResponseChannel restResponseChannel = new MockRestResponseChannel();
      method.invoke(frontendRestRequestService, restRequest, restResponseChannel);
      Exception e = restResponseChannel.getException();
      assertTrue("Unexpected exception", e instanceof IllegalStateException || e instanceof NullPointerException);
    }
  }
Checks reactions of all methods in {@link FrontendRestRequestService} to bad {@link RestResponseHandler} and
{@link RestRequest} implementations.
@throws Exception
ambry-frontend/src/test/java/com/github/ambry/frontend/FrontendRestRequestServiceTest.java