Apache Lucene open-source search software
SOLR-10473: Correct LBHttpSolrClient's confusing SolrServerException message when timeAllowed is exceeded.
Christine Poerschke23109b986298
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 128e386dec1..4627b2e094e 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -188,6 +188,9 @@ Bug Fixes* SOLR-10474: TestPointFields.testPointFieldReturn() depends on order of unsorted hits. (Steve Rowe)+* SOLR-10473: Correct LBHttpSolrClient's confusing SolrServerException message when timeAllowed is exceeded.+ (Christine Poerschke)+Other Changes----------------------diff --git a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.javaindex b0f1a505d0d..ed6ae7b99b2 100644--- a/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java+++ b/solr/solrj/src/java/org/apache/solr/client/solrj/impl/LBHttpSolrClient.java@@ -360,10 +360,11 @@ public class LBHttpSolrClient extends SolrClient {boolean isNonRetryable = req.request instanceof IsUpdateRequest || ADMIN_PATHS.contains(req.request.getPath());List<ServerWrapper> skipped = null;+ boolean timeAllowedExceeded = false;long timeAllowedNano = getTimeAllowedInNanos(req.getRequest());long timeOutTime = System.nanoTime() + timeAllowedNano;for (String serverStr : req.getServers()) {- if(isTimeExceeded(timeAllowedNano, timeOutTime)) {+ if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {break;}@@ -400,7 +401,7 @@ public class LBHttpSolrClient extends SolrClient {// try the servers we previously skippedif (skipped != null) {for (ServerWrapper wrapper : skipped) {- if(isTimeExceeded(timeAllowedNano, timeOutTime)) {+ if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {break;}@@ -417,10 +418,16 @@ public class LBHttpSolrClient extends SolrClient {}+ final String solrServerExceptionMessage;+ if (timeAllowedExceeded) {+ solrServerExceptionMessage = "Time allowed to handle this request exceeded";+ } else {+ solrServerExceptionMessage = "No live SolrServers available to handle this request";+ }if (ex == null) {- throw new SolrServerException("No live SolrServers available to handle this request");+ throw new SolrServerException(solrServerExceptionMessage);} else {- throw new SolrServerException("No live SolrServers available to handle this request:" + zombieServers.keySet(), ex);+ throw new SolrServerException(solrServerExceptionMessage+":" + zombieServers.keySet(), ex);}}@@ -593,10 +600,11 @@ public class LBHttpSolrClient extends SolrClient {int maxTries = serverList.length;Map<String,ServerWrapper> justFailed = null;+ boolean timeAllowedExceeded = false;long timeAllowedNano = getTimeAllowedInNanos(request);long timeOutTime = System.nanoTime() + timeAllowedNano;for (int attempts=0; attempts<maxTries; attempts++) {- if(isTimeExceeded(timeAllowedNano, timeOutTime)) {+ if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {break;}@@ -624,7 +632,7 @@ public class LBHttpSolrClient extends SolrClient {// try other standard servers that we didn't try just nowfor (ServerWrapper wrapper : zombieServers.values()) {- if(isTimeExceeded(timeAllowedNano, timeOutTime)) {+ if (timeAllowedExceeded = isTimeExceeded(timeAllowedNano, timeOutTime)) {break;}@@ -651,10 +659,16 @@ public class LBHttpSolrClient extends SolrClient {}+ final String solrServerExceptionMessage;+ if (timeAllowedExceeded) {+ solrServerExceptionMessage = "Time allowed to handle this request exceeded";+ } else {+ solrServerExceptionMessage = "No live SolrServers available to handle this request";+ }if (ex == null) {- throw new SolrServerException("No live SolrServers available to handle this request");+ throw new SolrServerException(solrServerExceptionMessage);} else {- throw new SolrServerException("No live SolrServers available to handle this request", ex);+ throw new SolrServerException(solrServerExceptionMessage, ex);}}