code: @Override
      @DoesServiceRequest
      public synchronized void flush() throws IOException {
          this.checkStreamState();
          
          // Dispatch a write for the current bytes in the buffer
          this.dispatchWrite(this.currentBufferedBytes);
          
          // Waits for all submitted tasks to complete
          while (this.outstandingRequests > 0) {
              // Wait for a task to complete
              this.waitForTaskToComplete();
              
              // If that task threw an error, fail fast
              this.checkStreamState();
          }
      }
docs: Flushes this output stream and forces any buffered output bytes to be written out. If any data remains in the
  buffer it is committed to the service.
  
  @throws IOException
  If an I/O error occurs.