Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-16229: Abort requests on exception (#1047)

Tomas Eduardo Fernandez Lobbe97e516b94a79
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ac524a185fc..495f0492088 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -194,7 +194,7 @@ Bug Fixes
* SOLR-16417: NPE if facet query hits timeout or exception (Kevin Risden)
-* SOLR-16414 : Race condition in PRS state updates (noble, Justin Sweeney, Patson Luk, Hitesh Khamesra, Ishan Chattopadhyaya)
+* SOLR-16414: Race condition in PRS state updates (noble, Justin Sweeney, Patson Luk, Hitesh Khamesra, Ishan Chattopadhyaya)
* SOLR-16418: Introduce SolrResponseUtil to handle NPE during query timeout or exception when parsing SolrResponse (Kevin Risden)
@@ -204,6 +204,8 @@ Bug Fixes
* SOLR-16232: Fix EnvVar usage in bin/solr (Houston Putman)
+* SOLR-16229: Http2SolrClient aborts requests on exception (Daniel Rabus, Tomás Fernández Löbbe)
+
Other Changes
---------------------
* SOLR-16351: Upgrade Carrot2 to 4.4.3, upgrade randomizedtesting to 2.8.0. (Dawid Weiss)
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 8f8230ae511..2c58e4a198b 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
@@ -451,22 +451,24 @@ public class Http2SolrClient extends SolrClient {
final ResponseParser parser =
solrRequest.getResponseParser() == null ? this.parser : solrRequest.getResponseParser();
+ Throwable abortCause = null;
try {
InputStreamResponseListener listener = new InputStreamResponseListener();
req.send(listener);
Response response = listener.get(idleTimeout, TimeUnit.MILLISECONDS);
InputStream is = listener.getInputStream();
assert ObjectReleaseTracker.track(is);
-
return processErrorsAndResponse(solrRequest, parser, response, is);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
+ abortCause = e;
throw new RuntimeException(e);
} catch (TimeoutException e) {
throw new SolrServerException(
"Timeout occured while waiting response from server at: " + req.getURI(), e);
} catch (ExecutionException e) {
Throwable cause = e.getCause();
+ abortCause = cause;
if (cause instanceof ConnectException) {
throw new SolrServerException("Server refused connection at: " + req.getURI(), cause);
}
@@ -477,6 +479,13 @@ public class Http2SolrClient extends SolrClient {
"IOException occured when talking to server at: " + getBaseURL(), cause);
}
throw new SolrServerException(cause.getMessage(), cause);
+ } catch (SolrServerException | RuntimeException sse) {
+ abortCause = sse;
+ throw sse;
+ } finally {
+ if (abortCause != null) {
+ req.abort(abortCause);
+ }
}
}