mirror of https://github.com/apache/lucene.git
SOLR-545 -- send an error if you hit the deprecated /update servlet within a MultiCore system...
git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@685645 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
4ede48a297
commit
53ac275c93
|
@ -16,6 +16,7 @@ package org.apache.solr.servlet;/**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
@ -25,6 +26,7 @@ import javax.servlet.http.HttpServlet;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.apache.solr.core.SolrResourceLoader;
|
||||||
import org.apache.solr.handler.XmlUpdateRequestHandler;
|
import org.apache.solr.handler.XmlUpdateRequestHandler;
|
||||||
import org.apache.solr.request.QueryResponseWriter;
|
import org.apache.solr.request.QueryResponseWriter;
|
||||||
import org.apache.solr.request.XMLResponseWriter;
|
import org.apache.solr.request.XMLResponseWriter;
|
||||||
|
@ -40,18 +42,29 @@ public class SolrUpdateServlet extends HttpServlet {
|
||||||
|
|
||||||
XmlUpdateRequestHandler legacyUpdateHandler;
|
XmlUpdateRequestHandler legacyUpdateHandler;
|
||||||
XMLResponseWriter xmlResponseWriter;
|
XMLResponseWriter xmlResponseWriter;
|
||||||
|
private boolean hasMulticore = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws ServletException
|
public void init() throws ServletException
|
||||||
{
|
{
|
||||||
legacyUpdateHandler = new XmlUpdateRequestHandler();
|
legacyUpdateHandler = new XmlUpdateRequestHandler();
|
||||||
legacyUpdateHandler.init( null );
|
legacyUpdateHandler.init( null );
|
||||||
|
|
||||||
|
// 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, "solr.xml");
|
||||||
|
hasMulticore = fconf.exists();
|
||||||
|
|
||||||
log.info("SolrUpdateServlet.init() done");
|
log.info("SolrUpdateServlet.init() done");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
|
||||||
|
if( hasMulticore ) {
|
||||||
|
response.sendError( 400, "Missing solr core name in path" );
|
||||||
|
return;
|
||||||
|
}
|
||||||
BufferedReader requestReader = request.getReader();
|
BufferedReader requestReader = request.getReader();
|
||||||
response.setContentType(QueryResponseWriter.CONTENT_TYPE_XML_UTF8);
|
response.setContentType(QueryResponseWriter.CONTENT_TYPE_XML_UTF8);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue