Fix for SOLR-4575, solr.core.* no longer respected when evaluating config files

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1456468 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2013-03-14 15:11:51 +00:00
parent 43af8ee91b
commit 55cb4b443f
2 changed files with 39 additions and 11 deletions

View File

@ -64,6 +64,8 @@ public class CoreDescriptor {
// them individually.
private Properties coreProperties = new Properties();
private boolean loadedImplicit = false;
private final CoreContainer coreContainer;
private CloudDescriptor cloudDesc;
@ -133,11 +135,11 @@ public class CoreDescriptor {
public Properties initImplicitProperties() {
Properties implicitProperties = new Properties(coreContainer.getContainerProperties());
implicitProperties.setProperty(CORE_NAME, getName());
implicitProperties.setProperty(CORE_INSTDIR, getInstanceDir());
implicitProperties.setProperty(CORE_DATADIR, getDataDir());
implicitProperties.setProperty(CORE_CONFIG, getConfigName());
implicitProperties.setProperty(CORE_SCHEMA, getSchemaName());
implicitProperties.setProperty("solr.core.name", getName());
implicitProperties.setProperty("solr.core.instanceDir", getInstanceDir());
implicitProperties.setProperty("solr.core.dataDir", getDataDir());
implicitProperties.setProperty("solr.core.configName", getConfigName());
implicitProperties.setProperty("solr.core.schemaName", getSchemaName());
return implicitProperties;
}
@ -251,13 +253,14 @@ public class CoreDescriptor {
* Under any circumstance, the properties passed in will override any already present.Merge
*/
public void setCoreProperties(Properties coreProperties) {
if (this.coreProperties == null) {
if (! loadedImplicit) {
loadedImplicit = true;
Properties p = initImplicitProperties();
this.coreProperties = new Properties(p);
}
// The caller presumably wants whatever properties passed in to override the current core props, so just add them.
if(coreProperties != null) {
this.coreProperties.putAll(coreProperties);
this.coreProperties.putAll(p);
// The caller presumably wants whatever properties passed in to override the current core props, so just add them.
if (coreProperties != null) {
this.coreProperties.putAll(coreProperties);
}
}
}

View File

@ -163,6 +163,18 @@ public class TestSolrDiscoveryProperties extends SolrTestCaseJ4 {
TestLazyCores.checkNotInCores(cc, "lazy1", "core2", "collection1");
SolrCore core1 = cc.getCore("core1");
// Let's assert we did the right thing for implicit properties too.
CoreDescriptor desc = core1.getCoreDescriptor();
assertEquals("core1", desc.getProperty("solr.core.name"));
// This is too long and ugly to put in. Besides, it varies.
assertNotNull(desc.getProperty("solr.core.instanceDir"));
assertEquals("stuffandnonsense", desc.getProperty("solr.core.dataDir"));
assertEquals("solrconfig-minimal.xml", desc.getProperty("solr.core.configName"));
assertEquals("schema-tiny.xml", desc.getProperty("solr.core.schemaName"));
SolrCore core2 = cc.getCore("core2");
SolrCore lazy1 = cc.getCore("lazy1");
TestLazyCores.checkInCores(cc, "core1", "core2", "lazy1");
@ -386,6 +398,19 @@ public class TestSolrDiscoveryProperties extends SolrTestCaseJ4 {
assertNull(props.getProperty("port")); // getProperty actually looks at original props.
assertNull(props.getProperty("cores.hostContext"));
assertNull(props.getProperty("cores.zkClientTimeout"));
SolrCore core1 = cc.getCore("collection1");
CoreDescriptor desc = core1.getCoreDescriptor();
assertEquals("collection1", desc.getProperty("solr.core.name"));
// This is too long and ugly to put in. Besides, it varies.
assertNotNull(desc.getProperty("solr.core.instanceDir"));
assertEquals("data/", desc.getProperty("solr.core.dataDir"));
assertEquals("solrconfig-minimal.xml", desc.getProperty("solr.core.configName"));
assertEquals("schema-tiny.xml", desc.getProperty("solr.core.schemaName"));
core1.close();
} finally {
cc.shutdown();
}