mirror of https://github.com/apache/lucene.git
SOLR-545 -- this aspect of SOLR-545 just fixes the behavior when a multicore environment falls through to /admin/ or /select via the SolrServlet
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@684606 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
72da2b2cbe
commit
bf41a13714
|
@ -315,6 +315,9 @@ public class SolrDispatchFilter implements Filter
|
|||
}
|
||||
}
|
||||
}
|
||||
if( core == null ) {
|
||||
req.setAttribute("org.apache.solr.NoCoreSet", Boolean.TRUE );
|
||||
}
|
||||
log.fine("no handler or core retrieved for " + path + ", follow through...");
|
||||
} catch (Throwable ex) {
|
||||
sendError( (HttpServletResponse)response, ex );
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
package org.apache.solr.servlet;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.logging.Logger;
|
||||
|
@ -28,6 +29,7 @@ import javax.servlet.http.HttpServletResponse;
|
|||
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.core.SolrCore;
|
||||
import org.apache.solr.core.SolrResourceLoader;
|
||||
import org.apache.solr.request.QueryResponseWriter;
|
||||
import org.apache.solr.request.SolrQueryResponse;
|
||||
import org.apache.solr.request.SolrRequestHandler;
|
||||
|
@ -39,9 +41,17 @@ import org.apache.solr.request.SolrRequestHandler;
|
|||
public class SolrServlet extends HttpServlet {
|
||||
|
||||
final Logger log = Logger.getLogger(SolrServlet.class.getName());
|
||||
private boolean hasMulticore = false;
|
||||
|
||||
public void init() throws ServletException {
|
||||
log.info("SolrServlet.init()");
|
||||
|
||||
// Check if the "multicore.xml" file exists -- if so, this is an invalid servlet
|
||||
// (even if there is only one core...)
|
||||
String instanceDir = SolrResourceLoader.locateInstanceDir();
|
||||
File fconf = new File(instanceDir, "multicore.xml");
|
||||
hasMulticore = fconf.exists();
|
||||
|
||||
// we deliberately do not initialize a SolrCore because of SOLR-597
|
||||
// https://issues.apache.org/jira/browse/SOLR-597
|
||||
log.info("SolrServlet.init() done");
|
||||
|
@ -52,6 +62,11 @@ public class SolrServlet extends HttpServlet {
|
|||
}
|
||||
|
||||
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||
if( hasMulticore ) {
|
||||
response.sendError( 400, "Missing solr core name in path" );
|
||||
return;
|
||||
}
|
||||
|
||||
final SolrCore core = SolrCore.getSolrCore();
|
||||
SolrServletRequest solrReq = new SolrServletRequest(core, request);;
|
||||
SolrQueryResponse solrRsp = new SolrQueryResponse();
|
||||
|
|
|
@ -22,13 +22,15 @@
|
|||
<%@ page import="java.io.StringWriter"%>
|
||||
<%@ page import="org.apache.solr.core.Config"%>
|
||||
<%@ page import="org.apache.solr.common.util.XML"%>
|
||||
<%@ page import="org.apache.solr.common.SolrException"%>
|
||||
<%@ page import="org.apache.lucene.LucenePackage"%>
|
||||
<%@ page import="java.net.UnknownHostException" %>
|
||||
<%
|
||||
//
|
||||
SolrCore core = (SolrCore) request.getAttribute("org.apache.solr.SolrCore");
|
||||
if (core == null)
|
||||
core = SolrCore.getSolrCore();
|
||||
if (core == null) {
|
||||
throw new SolrException( SolrException.ErrorCode.BAD_REQUEST, "missing core name" );
|
||||
}
|
||||
|
||||
SolrConfig solrConfig = core.getSolrConfig();
|
||||
int port = request.getServerPort();
|
||||
|
|
Loading…
Reference in New Issue