private void discardRequests() {
    logger.trace("Discarding requests on account of shutdown");
    RestServiceException e = new RestServiceException("Service shutdown", RestServiceErrorCode.ServiceUnavailable);
    AsyncRequestInfo residualRequestInfo = requests.poll();
    int discardCount = 0;
    while (residualRequestInfo != null) {
      if (residualRequestInfo.restRequest != null) {
        discardCount++;
        onRequestDequeue(residualRequestInfo);
        onProcessingFailure(residualRequestInfo.restRequest, residualRequestInfo.restResponseChannel, e);
      }
      residualRequestInfo = requests.poll();
    }
    if (discardCount > 0) {
      metrics.residualRequestQueueSize.inc(discardCount);
      logger.info("There were {} requests in flight during shutdown", discardCount);
    }
  }
Called on shutdown and empties the remaining requests and releases resources held by them.
ambry-rest/src/main/java/com/github/ambry/rest/AsyncRequestResponseHandler.java