Skip to content

Apache Lucene open-source search software

SOLR-8068: Check and throw exception in the SDF early if the core container wasn't initialized properly or is shutting down.

Anshum Gupta498cafc40a9e
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index 16f18d08933..06343176e45 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -282,6 +282,9 @@ Other Changes
* SOLR-8066: SolrCore.checkStale method doesn't restore interrupt status. (shalin)
+* SOLR-8068: Throw a SolrException if the core container has initialization errors or is
+ shutting down (Ishan Chattopadhyaya, Noble Paul, Anshum Gupta)
+
================== 5.3.1 ==================
Bug Fixes
diff --git a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
index 2e49a97edd5..10b6f95c812 100644
--- a/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
+++ b/solr/core/src/java/org/apache/solr/servlet/SolrDispatchFilter.java
@@ -182,6 +182,12 @@ public class SolrDispatchFilter extends BaseSolrFilter {
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain, boolean retry) throws IOException, ServletException {
if (!(request instanceof HttpServletRequest)) return;
+ if (cores == null || cores.isShutDown()) {
+ log.error("Error processing the request. CoreContainer is either not initialized or shutting down.");
+ throw new SolrException(ErrorCode.SERVICE_UNAVAILABLE,
+ "Error processing the request. CoreContainer is either not initialized or shutting down.");
+ }
+
AtomicReference<ServletRequest> wrappedRequest = new AtomicReference<>();
if (!authenticateRequest(request, response, wrappedRequest)) { // the response and status code have already been sent
return;