mirror of https://github.com/apache/lucene.git
SOLR-5494: CoreContainer#remove throws NPE rather than returning null when a SolrCore does not exist in core discovery mode.
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1544844 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b892c597f7
commit
aa253e949f
|
@ -103,6 +103,9 @@ New Features
|
||||||
This is intended to eventually replace the Suggester support through the
|
This is intended to eventually replace the Suggester support through the
|
||||||
SpellCheckComponent. (Areek Zillur, Varun Thacker via shalin)
|
SpellCheckComponent. (Areek Zillur, Varun Thacker via shalin)
|
||||||
|
|
||||||
|
* SOLR-5494: CoreContainer#remove throws NPE rather than returning null when
|
||||||
|
a SolrCore does not exist in core discovery mode. (Mark Miller)
|
||||||
|
|
||||||
Bug Fixes
|
Bug Fixes
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,11 @@ public class CorePropertiesLocator implements CoresLocator {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void delete(CoreContainer cc, CoreDescriptor... coreDescriptors) {
|
public void delete(CoreContainer cc, CoreDescriptor... coreDescriptors) {
|
||||||
|
if (coreDescriptors == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (CoreDescriptor cd : coreDescriptors) {
|
for (CoreDescriptor cd : coreDescriptors) {
|
||||||
|
if (cd == null) continue;
|
||||||
File instanceDir = new File(cd.getInstanceDir());
|
File instanceDir = new File(cd.getInstanceDir());
|
||||||
File propertiesFile = new File(instanceDir, PROPERTIES_FILENAME);
|
File propertiesFile = new File(instanceDir, PROPERTIES_FILENAME);
|
||||||
propertiesFile.renameTo(new File(instanceDir, PROPERTIES_FILENAME + ".unloaded"));
|
propertiesFile.renameTo(new File(instanceDir, PROPERTIES_FILENAME + ".unloaded"));
|
||||||
|
|
|
@ -149,7 +149,10 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
//create solrHome
|
//create solrHome
|
||||||
File solrHomeDirectory = new File(TEMP_DIR, this.getClass().getName()
|
File solrHomeDirectory = new File(TEMP_DIR, this.getClass().getName()
|
||||||
+ "_noCores");
|
+ "_noCores");
|
||||||
SetUpHome(solrHomeDirectory, EMPTY_SOLR_XML);
|
|
||||||
|
boolean oldSolrXml = random().nextBoolean();
|
||||||
|
|
||||||
|
SetUpHome(solrHomeDirectory, oldSolrXml ? EMPTY_SOLR_XML : EMPTY_SOLR_XML2);
|
||||||
CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
|
CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
|
||||||
cores.load();
|
cores.load();
|
||||||
try {
|
try {
|
||||||
|
@ -166,14 +169,19 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
assertEquals("There core registered", 1, cores.getCores().size());
|
assertEquals("There core registered", 1, cores.getCores().size());
|
||||||
|
|
||||||
|
if (oldSolrXml) {
|
||||||
assertXmlFile(new File(solrHomeDirectory, "solr.xml"),
|
assertXmlFile(new File(solrHomeDirectory, "solr.xml"),
|
||||||
"/solr/cores[@transientCacheSize='32']");
|
"/solr/cores[@transientCacheSize='32']");
|
||||||
|
}
|
||||||
|
|
||||||
newCore.close();
|
newCore.close();
|
||||||
cores.remove("core1");
|
cores.remove("core1");
|
||||||
//assert cero cores
|
//assert cero cores
|
||||||
assertEquals("There should not be cores", 0, cores.getCores().size());
|
assertEquals("There should not be cores", 0, cores.getCores().size());
|
||||||
|
|
||||||
|
// try and remove a core that does not exist
|
||||||
|
SolrCore ret = cores.remove("non_existent_core");
|
||||||
|
assertNull(ret);
|
||||||
} finally {
|
} finally {
|
||||||
cores.shutdown();
|
cores.shutdown();
|
||||||
FileUtils.deleteDirectory(solrHomeDirectory);
|
FileUtils.deleteDirectory(solrHomeDirectory);
|
||||||
|
@ -275,4 +283,8 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
|
||||||
" <cores adminPath=\"/admin/cores\" transientCacheSize=\"32\" >\n" +
|
" <cores adminPath=\"/admin/cores\" transientCacheSize=\"32\" >\n" +
|
||||||
" </cores>\n" +
|
" </cores>\n" +
|
||||||
"</solr>";
|
"</solr>";
|
||||||
|
|
||||||
|
private static final String EMPTY_SOLR_XML2 ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
|
||||||
|
"<solr>\n" +
|
||||||
|
"</solr>";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue