This is an automated email from the ASF dual-hosted git repository.

dsmiley pushed a commit to branch branch_10_0
in repository https://gitbox.apache.org/repos/asf/solr.git

commit 551f20ca656ec2fe24795a01bbcb88cefa504361
Author: David Smiley <[email protected]>
AuthorDate: Thu Oct 23 11:12:01 2025 -0400

    SOLR-17897: CloudSolrClient: treat UnknownHostException as retry-able 
(#3791)
    
    CloudSolrClient now recognizes UnknownHostException as a case to refetch 
the cluster state and retry.  A "commError".
---
 solr/CHANGES.txt                                             |  3 +++
 .../apache/solr/client/solrj/impl/CloudHttp2SolrClient.java  |  5 -----
 .../apache/solr/client/solrj/impl/CloudLegacySolrClient.java |  3 ++-
 .../org/apache/solr/client/solrj/impl/CloudSolrClient.java   | 12 ++++++------
 4 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 952b33034d3..a4aafdf11c4 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -555,6 +555,9 @@ Improvements
 * SOLR-17921: SolrJ CloudSolrClient configured with a Solr URL (not ZK) now 
refreshes liveNodes in the background.
   This will reduce spikes in request latency when the cached liveNodes have 
expired. (Houston Putman, David Smiley)
 
+* SOLR-17897: CloudSolrClient now recognizes UnknownHostException as a case to 
refetch the cluster
+  state and retry.  (David Smiley)
+
 Optimizations
 ---------------------
 (No changes)
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
index 4b3ac046ac2..0bb4d3eb67a 100644
--- 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
+++ 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudHttp2SolrClient.java
@@ -182,11 +182,6 @@ public class CloudHttp2SolrClient extends CloudSolrClient {
     return myClient;
   }
 
-  @Override
-  protected boolean wasCommError(Throwable rootCause) {
-    return false;
-  }
-
   /** Constructs {@link CloudHttp2SolrClient} instances from provided 
configuration. */
   public static class Builder {
     protected Collection<String> zkHosts = new ArrayList<>();
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
index e8aecc8a88b..2c660c63228 100644
--- 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
+++ 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudLegacySolrClient.java
@@ -140,7 +140,8 @@ public class CloudLegacySolrClient extends CloudSolrClient {
 
   @Override
   protected boolean wasCommError(Throwable rootCause) {
-    return rootCause instanceof ConnectTimeoutException
+    return super.wasCommError(rootCause)
+        || rootCause instanceof ConnectTimeoutException
         || rootCause instanceof NoHttpResponseException;
   }
 
diff --git 
a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java 
b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
index ebe1fddf0ee..ac12e5b5722 100644
--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/CloudSolrClient.java
@@ -21,8 +21,8 @@ import static org.apache.solr.common.params.CommonParams.ID;
 
 import java.io.IOException;
 import java.lang.invoke.MethodHandles;
-import java.net.ConnectException;
 import java.net.SocketException;
+import java.net.UnknownHostException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -221,7 +221,10 @@ public abstract class CloudSolrClient extends SolrClient {
     return getClusterStateProvider().getClusterState();
   }
 
-  protected abstract boolean wasCommError(Throwable t);
+  /** Is this a communication error? We will retry if so. */
+  protected boolean wasCommError(Throwable t) {
+    return t instanceof SocketException || t instanceof UnknownHostException;
+  }
 
   @Override
   public void close() throws IOException {
@@ -813,10 +816,7 @@ public abstract class CloudSolrClient extends SolrClient {
               ? ((SolrException) rootCause).code()
               : SolrException.ErrorCode.UNKNOWN.code;
 
-      boolean wasCommError =
-          (rootCause instanceof ConnectException
-              || rootCause instanceof SocketException
-              || wasCommError(rootCause));
+      final boolean wasCommError = wasCommError(rootCause);
 
       if (wasCommError
           || (exc instanceof RouteException

Reply via email to