code: private void waitForTaskToComplete() throws IOException {
          try {
              final Future<Void> future = this.completionService.take();
              future.get();
          }
          catch (final InterruptedException e) {
              throw Utility.initIOException(e);
          }
          catch (final ExecutionException e) {
              throw Utility.initIOException(e);
          }
  
          this.outstandingRequests--;
      }
docs: Waits for one task to complete
  
  @throws IOException
  If an I/O error occurs. In particular, an IOException may be thrown if the output stream has been
  closed.