mirror of https://github.com/apache/lucene.git
SOLR-7529: CoreAdminHandler Reload throws NPE on null core name instead of a bad request error
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1690426 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2c64848c78
commit
07a615fd65
|
@ -227,6 +227,9 @@ Bug Fixes
|
||||||
* SOLR-7705: CoreAdminHandler Unload no longer handles null core name and throws NPE
|
* SOLR-7705: CoreAdminHandler Unload no longer handles null core name and throws NPE
|
||||||
instead of a bad request error. (John Call, Edward Ribeiro via shalin)
|
instead of a bad request error. (John Call, Edward Ribeiro via shalin)
|
||||||
|
|
||||||
|
* SOLR-7529: CoreAdminHandler Reload throws NPE on null core name instead of a bad
|
||||||
|
request error. (Jellyfrog, Edward Ribeiro via shalin)
|
||||||
|
|
||||||
Optimizations
|
Optimizations
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -766,7 +766,7 @@ public class CoreAdminHandler extends RequestHandlerBase {
|
||||||
SolrParams params = req.getParams();
|
SolrParams params = req.getParams();
|
||||||
String cname = params.get(CoreAdminParams.CORE);
|
String cname = params.get(CoreAdminParams.CORE);
|
||||||
|
|
||||||
if(!coreContainer.getCoreNames().contains(cname)) {
|
if (cname == null || !coreContainer.getCoreNames().contains(cname)) {
|
||||||
throw new SolrException(ErrorCode.BAD_REQUEST, "Core with core name [" + cname + "] does not exist.");
|
throw new SolrException(ErrorCode.BAD_REQUEST, "Core with core name [" + cname + "] does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -243,5 +243,21 @@ public class CoreAdminHandlerTest extends SolrTestCaseJ4 {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
assertEquals("Expected error message for non-existent core.", "Core with core name [non-existent-core] does not exist.", e.getMessage());
|
assertEquals("Expected error message for non-existent core.", "Core with core name [non-existent-core] does not exist.", e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test null core
|
||||||
|
try {
|
||||||
|
admin.handleRequestBody(
|
||||||
|
req(CoreAdminParams.ACTION,
|
||||||
|
CoreAdminParams.CoreAdminAction.RELOAD.toString())
|
||||||
|
, resp);
|
||||||
|
fail("Was able to successfully reload null core");
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
if (!(e instanceof SolrException)) {
|
||||||
|
fail("Expected SolrException but got " + e);
|
||||||
|
}
|
||||||
|
assertEquals("Expected error message for non-existent core.", "Core with core name [null] does not exist.", e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue