rishisankar commented on a change in pull request #1770: URL: https://github.com/apache/lucene-solr/pull/1770#discussion_r489566851
########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/SolrRequest.java ########## @@ -260,18 +260,13 @@ public final T process(SolrClient client) throws SolrServerException, IOExceptio public final CompletableFuture<T> processAsynchronously(SolrClient client, String collection) { final long startNanos = System.nanoTime(); final CompletableFuture<NamedList<Object>> internalFuture = client.requestAsync(this, collection); - final CompletableFuture<T> apiFuture = new CompletableFuture<>(); - - internalFuture.whenComplete((result, error) -> { - if (!internalFuture.isCompletedExceptionally()) { - T res = createResponse(client); - res.setResponse(result); - long endNanos = System.nanoTime(); - res.setElapsedTime(TimeUnit.NANOSECONDS.toMillis(endNanos - startNanos)); - apiFuture.complete(res); - } else { - apiFuture.completeExceptionally(error); - } + + final CompletableFuture<T> apiFuture = internalFuture.thenApply((result) -> { Review comment: If internalFuture completes exceptionally, apiFuture will complete exceptionally with a `CompletionException` (with internalFuture's exception as its cause). That being said, I think it's better to not have a CompletionException wrapper around the actual exception, so I'll revert to using whenComplete instead of thenApply. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org