CaoManhDat commented on a change in pull request #1770: URL: https://github.com/apache/lucene-solr/pull/1770#discussion_r481568904
########## File path: solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttp2SolrClient.java ########## @@ -112,95 +112,106 @@ public void onFailure(Exception e, boolean retryReq) { if (cancelled.get()) { return; } - Cancellable cancellable = doRequest(url, req, rsp, isNonRetryable, it.isServingZombieServer(), this); - currentCancellable.set(cancellable); + CompletableFuture<NamedList<Object>> future = doAsyncRequest(url, req, rsp, isNonRetryable, it.isServingZombieServer(), this); + currentFuture.set(future); } } finally { MDC.remove("LBSolrClient.url"); } } else { - asyncListener.onFailure(e); + apiFuture.completeExceptionally(e); } } }; try { - Cancellable cancellable = doRequest(it.nextOrError(), req, rsp, isNonRetryable, it.isServingZombieServer(), retryListener); - currentCancellable.set(cancellable); + CompletableFuture<NamedList<Object>> future = doAsyncRequest(it.nextOrError(), req, rsp, isNonRetryable, it.isServingZombieServer(), retryListener); + currentFuture.set(future); } catch (SolrServerException e) { - asyncListener.onFailure(e); + apiFuture.completeExceptionally(e); } - return () -> { - synchronized (cancelled) { - cancelled.set(true); - if (currentCancellable.get() != null) { - currentCancellable.get().cancel(); + apiFuture.exceptionally((error) -> { + if (apiFuture.isCancelled()) { + synchronized (cancelled) { + cancelled.set(true); + if (currentFuture.get() != null) { Review comment: > Maybe we don't need RL but we just need a static utility method somewhere like boolean shouldRetry(Exception e) Yeah something like that, so the first CF will have an `exceptionally` handler which create a new CF on exception, etc. ---------------------------------------------------------------- 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