This is an automated email from the ASF dual-hosted git repository.
houston pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 1490cf82023 Catch cancellation exceptions - Fix TestTolerantSearch
(#3393)
1490cf82023 is described below
commit 1490cf820233243a57d2581eb660a8776968b6c3
Author: Houston Putman <[email protected]>
AuthorDate: Wed Jun 25 16:45:26 2025 -0500
Catch cancellation exceptions - Fix TestTolerantSearch (#3393)
Co-authored-by: David Smiley <[email protected]>
---
.../java/org/apache/solr/client/solrj/impl/Http2SolrClient.java | 9 ++++++++-
.../solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java | 2 ++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
index 1259bc85a7c..4535013a72b 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/Http2SolrClient.java
@@ -30,6 +30,7 @@ import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Objects;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
@@ -521,7 +522,13 @@ public class Http2SolrClient extends HttpSolrClientBase {
mdcCopyHelper.onBegin(null);
log.debug("response processing success");
future.complete(body);
- } catch (SolrClient.RemoteSolrException |
SolrServerException e) {
+ } catch (CancellationException e) {
+ mdcCopyHelper.onBegin(null);
+ log.debug("response processing cancelled", e);
+ if (!future.isDone()) {
+ future.cancel(true);
+ }
+ } catch (Throwable e) {
mdcCopyHelper.onBegin(null);
log.debug("response processing failed", e);
future.completeExceptionally(e);
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
index 129ec8df8ca..e6e1cd44941 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/ExecutorUtil.java
@@ -24,6 +24,7 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
+import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
@@ -378,6 +379,7 @@ public class ExecutorUtil {
}
try {
command.run();
+ } catch (CancellationException ignored) {
} catch (Throwable t) {
if (t instanceof OutOfMemoryError) {
throw t;