dsmiley commented on a change in pull request #1770:
URL: https://github.com/apache/lucene-solr/pull/1770#discussion_r481171793
##########
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:
With CompletableFuture, there's no harm in attempting to complete a
future redundantly -- it's a no-op. Thus if currentFuture is already
cancelled, no extra work.
Removing RetryListener might mean not doing retry-s? How do you propose
retry-s be done without RL? *Maybe* we don't need RL but we just need a static
utility method somewhere like `boolean shouldRetry(Exception e)`?
----------------------------------------------------------------
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:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]