Apache Lucene open-source search software
SOLR-8422: When authentication enabled, requests fail if sent to a node that doesn't host the collection
Noble Paul0afacabbcdc0
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex f810ba69dff..8fac0cf3955 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -286,6 +286,9 @@ Bug Fixes* SOLR-8015: HdfsLock may fail to close a FileSystem instance if it cannot immediatelyobtain an index lock. (Mark Miller)+* SOLR-8422: When authentication enabled, requests fail if sent to a node that doesn't host+ the collection (noble)+Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.javaindex 2784dbe5549..cc1447373f4 100644--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java@@ -219,8 +219,9 @@ public class SolrDispatchFilter extends BaseSolrFilter {}}}-+HttpSolrCall call = getHttpSolrCall((HttpServletRequest) request, (HttpServletResponse) response, retry);+ ExecutorUtil.setServerThreadFlag(Boolean.TRUE);try {Action result = call.call();switch (result) {@@ -236,6 +237,7 @@ public class SolrDispatchFilter extends BaseSolrFilter {}} finally {call.destroy();+ ExecutorUtil.setServerThreadFlag(null);}}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.javaindex f8f09c987eb..f3cdfbd5dbd 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@@ -255,8 +255,15 @@ public class ExecutorUtil {private static final ThreadLocal<Boolean> isServerPool = new ThreadLocal<>();+ /// this tells whether a thread is owned/run by solr or not.public static boolean isSolrServerThread() {return Boolean.TRUE.equals(isServerPool.get());}+ public static void setServerThreadFlag(Boolean flag) {+ if (flag == null) isServerPool.remove();+ else isServerPool.set(flag);++ }+}