code: public static <V> CompletableFuture<V> toCompletableFuture(ListenableFuture<V> listenableFuture)
      {
          requireNonNull(listenableFuture, "listenableFuture is null");
  
          CompletableFuture<V> future = new CompletableFuture<>();
          future.exceptionally(throwable -> {
              if (throwable instanceof CancellationException) {
                  listenableFuture.cancel(true);
              }
              return null;
          });
  
          FutureCallback<V> callback = new FutureCallback<V>()
          {
              @Override
              public void onSuccess(V result)
              {
                  future.complete(result);
              }
  
              @Override
              public void onFailure(Throwable t)
              {
                  future.completeExceptionally(t);
              }
          };
          Futures.addCallback(listenableFuture, callback, directExecutor());
          return future;
      }
docs: Converts a ListenableFuture to a CompletableFuture. Cancellation of the
  CompletableFuture will be propagated to the ListenableFuture.