CaoManhDat commented on a change in pull request #1770:
URL: https://github.com/apache/lucene-solr/pull/1770#discussion_r481026906



##########
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:
       Should we need to synchronized by `cancelled` here? The worst case here 
is cancel() will be called on previous future. 
   Another point here is should we remove RetryListener here? With the 
`CompletableFuture` features, `RetryListener` just making things more complex.




----------------------------------------------------------------
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

Reply via email to