@Test
public void testRestoreAfterFail() throws FlowController.FlowControlException {

  FlowController flowController =
      new FlowController(
          FlowControlSettings.newBuilder()
              .setMaxOutstandingElementCount(2L)
              .setMaxOutstandingRequestBytes(1L)
              .setLimitExceededBehavior(LimitExceededBehavior.ThrowException)
              .build());
  flowController.reserve(1, 1);
  try {
    flowController.reserve(1, 1);
    throw new IllegalStateException("flowController should not have any bytes left");
  } catch (FlowController.MaxOutstandingRequestBytesReachedException e) {
    // Ignore.
  }
  flowController.reserve(1, 0);
}