@Override public void startCancel() { Status status = status(); if (status == Status.PENDING) { throw new IllegalStateException("Can't cancel this RPC, not currently active."); } else if (status == Status.COMPLETE) { // We drop these requests silently - since there is no way for the client // to know whether the RPC has finished while they are setting up their // cancellation. } else { state.cancelRpc.run(); } } }
/** * Assert that this controller is in the given status. */ private void checkStatus(Status statusToAssert) { Status currentStatus = status(); if (!currentStatus.equals(statusToAssert)) { throw new IllegalStateException("Controller expected status " + statusToAssert + ", was " + currentStatus); } }