SOLR-965: Better error message when <pingQuery> is not configured.

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@769574 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Chris M. Hostetter 2009-04-28 22:23:48 +00:00
parent 97db6150fa
commit 88249e3977
3 changed files with 20 additions and 16 deletions

View File

@ -349,6 +349,9 @@ Bug Fixes
39. SOLR-1094: Incorrect value of correctlySpelled attribute in some cases (David Smiley, mark Miller via shalin)
40. SOLR-965: Better error message when <pingQuery> is not configured.
(Mark Miller via hossman)
Other Changes
----------------------
1. Upgraded to Lucene 2.4.0 (yonik)

View File

@ -27,6 +27,9 @@ import org.apache.solr.search.FastLRUCache;
import org.apache.solr.update.SolrIndexConfig;
import org.apache.lucene.search.BooleanQuery;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
@ -48,6 +51,8 @@ import java.io.InputStream;
*/
public class SolrConfig extends Config {
public static final Logger log = LoggerFactory.getLogger(SolrConfig.class);
public static final String DEFAULT_CONF_FILE = "solrconfig.xml";
/**
@ -202,7 +207,6 @@ public class SolrConfig extends Config {
private final NamedList pingQueryParams;
static private NamedList readPingQueryParams(SolrConfig config) {
// TODO: check for nested tags and parse as a named list instead
String urlSnippet = config.get("admin/pingQuery", "").trim();
StringTokenizer qtokens = new StringTokenizer(urlSnippet,"&");
@ -213,6 +217,10 @@ public class SolrConfig extends Config {
String[] split = tok.split("=", 2);
params.add(split[0], split[1]);
}
if (0 < params.size()) {
log.warn("The <pingQuery> syntax is deprecated, " +
"please use PingRequestHandler instead");
}
return params;
}
@ -224,6 +232,11 @@ public class SolrConfig extends Config {
*/
@Deprecated
public SolrQueryRequest getPingQueryRequest(SolrCore core) {
if(pingQueryParams.size() == 0) {
throw new IllegalStateException
("<pingQuery> not configured (consider registering " +
"PingRequestHandler with the name '/admin/ping' instead)");
}
return new LocalSolrQueryRequest(core, pingQueryParams);
}

View File

@ -37,25 +37,13 @@
if (resp.getException() == null) {
// No need for explicit status in the body, when the standard HTTP
// response codes already transmit success/failure message
// out.println("<status>200</status>");
out.println("<status>200</status>");
}
else if (resp.getException() != null) {
// No need for explicit status in the body, when the standard HTTP
// response codes already transmit success/failure message
// out.println("<status>500</status>");
out.println("<error>");
XML.escapeCharData(SolrException.toStr(resp.getException()), out);
out.println("</error>");
response.sendError(500);
throw resp.getException();
}
} catch (Throwable t) {
// No need for explicit status in the body, when the standard HTTP
// response codes already transmit success/failure message
// out.println("<status>500</status>");
out.println("<error>");
XML.escapeCharData(SolrException.toStr(t), out);
out.println("</error>");
response.sendError(500);
throw t;
} finally {
req.close();
}