code: protected void waitForPromiseSuccess() throws IOException, TimeoutException {
      while(!promise.isDone() && !promise.isCancelled()) {
        Promise<T> listeningPromise = this.promise;
        listeningPromise.awaitUninterruptibly();
        if (listeningPromise == this.promise) {
          this.handlePromise(promise);
          break;
        }
      }
    }
docs: Wait for promise to be done
  
  @throws IOException      on IOException
  @throws TimeoutException on timeout