SOLR-5632: Improve response message for reloading a non-existent core.

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1558459 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2014-01-15 16:44:25 +00:00
parent 32ca6db738
commit e5b31d2904
3 changed files with 25 additions and 1 deletions

View File

@ -266,6 +266,9 @@ Other Changes
* SOLR-2794: change the default of hl.phraseLimit to 5000.
(Michael Della Bitta via Robert Muir, Koji, zarni - pull request #11)
* SOLR-5632: Improve response message for reloading a non-existent core.
(Anshum Gupta via Mark Miller)
================== 4.6.1 ==================
Versions of Major Components

View File

@ -725,6 +725,11 @@ public class CoreAdminHandler extends RequestHandlerBase {
protected void handleReloadAction(SolrQueryRequest req, SolrQueryResponse rsp) {
SolrParams params = req.getParams();
String cname = params.get(CoreAdminParams.CORE);
if(coreContainer.getCore(cname) == null) {
throw new SolrException(ErrorCode.BAD_REQUEST, "Core with core name [" + cname + "] does not exist.");
}
try {
coreContainer.reload(cname);
} catch (Exception ex) {
@ -775,7 +780,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
core.getUpdateHandler().getSolrCoreState().doRecovery(coreContainer, core.getCoreDescriptor());
} else {
SolrException.log(log, "Cound not find core to call recovery:" + cname);
SolrException.log(log, "Could not find core to call recovery:" + cname);
}
} finally {
// no recoveryStrat close for now

View File

@ -274,4 +274,20 @@ public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
}
}
@Test
public void testNonexistentCoreReload() throws Exception {
final CoreAdminHandler admin = new CoreAdminHandler(h.getCoreContainer());
SolrQueryResponse resp = new SolrQueryResponse();
try {
admin.handleRequestBody(
req(CoreAdminParams.ACTION,
CoreAdminParams.CoreAdminAction.RELOAD.toString(),
CoreAdminParams.CORE, "non-existent-core")
, resp);
fail("Was able to successfully reload non-existent-core");
} catch (Exception e) {
assertEquals("Expected error message for non-existent core.", "Core with core name [non-existent-core] does not exist.", e.getMessage());
}
}
}