code: private void awaitRequestsCompletion() throws IOException {
      // Don't wait until all requests will be completed if enough requests are pending for full batch
      while (!responseFutures.isEmpty() && pendingRequests.size() < maxRequestsPerBatch) {
        try {
          responseFutures.remove().get();
        } catch (InterruptedException | ExecutionException e) {
          if (e.getCause() instanceof IOException) {
            throw (IOException) e.getCause();
          }
          throw new RuntimeException("Failed to execute batch", e);
        }
      }
    }
docs: Awaits until all sent requests are completed. Should be serialized