Apache Lucene open-source search software
SOLR-3629: Typo in solr.xml persistence when overriding the solrconfig.xml file name using the "config" attribute prevented the override file from being used
Chris M. Hostetterb20252f777d7
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex 64d4f1d222d..2db8205b622 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -108,6 +108,11 @@ Bug Fixes* SOLR-3639: Update ZooKeeper to 3.3.5 for a variety of bug fixes. (Mark Miller)+* SOLR-3629: Typo in solr.xml persistence when overriding the solrconfig.xml+ file name using the "config" attribute prevented the override file from being+ used. (Ryan Zezeski, hossman)++Other Changes----------------------diff --git a/solr/core/src/java/org/apache/solr/core/CoreContainer.java b/solr/core/src/java/org/apache/solr/core/CoreContainer.javaindex ef3fdbb4092..2d02ee14465 100644--- a/solr/core/src/java/org/apache/solr/core/CoreContainer.java+++ b/solr/core/src/java/org/apache/solr/core/CoreContainer.java@@ -96,6 +96,18 @@ public class CoreContainerprotected static Logger log = LoggerFactory.getLogger(CoreContainer.class);+ // solr.xml node constants+ private static final String CORE_NAME = "name";+ private static final String CORE_CONFIG = "config";+ private static final String CORE_INSTDIR = "instanceDir";+ private static final String CORE_DATADIR = "dataDir";+ private static final String CORE_SCHEMA = "schema";+ private static final String CORE_SHARD = "shard";+ private static final String CORE_COLLECTION = "collection";+ private static final String CORE_ROLES = "roles";+ private static final String CORE_PROPERTIES = "properties";++protected final Map<String, SolrCore> cores = new LinkedHashMap<String, SolrCore>();protected boolean persistent = false;protected String adminPath = null;@@ -477,43 +489,43 @@ public class CoreContainerfor (int i=0; i<nodes.getLength(); i++) {Node node = nodes.item(i);try {- String rawName = DOMUtil.getAttr(node, "name", null);+ String rawName = DOMUtil.getAttr(node, CORE_NAME, null);if (null == rawName) {throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,"Each core in solr.xml must have a 'name'");}String name = rawName;- CoreDescriptor p = new CoreDescriptor(this, name, DOMUtil.getAttr(node, "instanceDir", null));+ CoreDescriptor p = new CoreDescriptor(this, name, DOMUtil.getAttr(node, CORE_INSTDIR, null));// deal with optional settings- String opt = DOMUtil.getAttr(node, "config", null);+ String opt = DOMUtil.getAttr(node, CORE_CONFIG, null);if (opt != null) {p.setConfigName(opt);}- opt = DOMUtil.getAttr(node, "schema", null);+ opt = DOMUtil.getAttr(node, CORE_SCHEMA, null);if (opt != null) {p.setSchemaName(opt);}if (zkController != null) {- opt = DOMUtil.getAttr(node, "shard", null);+ opt = DOMUtil.getAttr(node, CORE_SHARD, null);if (opt != null && opt.length() > 0) {p.getCloudDescriptor().setShardId(opt);}- opt = DOMUtil.getAttr(node, "collection", null);+ opt = DOMUtil.getAttr(node, CORE_COLLECTION, null);if (opt != null) {p.getCloudDescriptor().setCollectionName(opt);}- opt = DOMUtil.getAttr(node, "roles", null);+ opt = DOMUtil.getAttr(node, CORE_ROLES, null);if(opt != null){p.getCloudDescriptor().setRoles(opt);}}- opt = DOMUtil.getAttr(node, "properties", null);+ opt = DOMUtil.getAttr(node, CORE_PROPERTIES, null);if (opt != null) {p.setPropertiesName(opt);}- opt = DOMUtil.getAttr(node, CoreAdminParams.DATA_DIR, null);+ opt = DOMUtil.getAttr(node, CORE_DATADIR, null);if (opt != null) {p.setDataDir(opt);}@@ -1154,7 +1166,7 @@ public class CoreContainerfor (int i = 0; i < nodes.getLength(); i++) {Node node = nodes.item(i);- String name = DOMUtil.getAttr(node, "name", null);+ String name = DOMUtil.getAttr(node, CORE_NAME, null);if (origCoreName.equals(name)) {coreNode = node;if (coreName.equals(origCoreName)) {@@ -1168,7 +1180,7 @@ public class CoreContainer// see if we match with substitutionfor (int i = 0; i < nodes.getLength(); i++) {Node node = nodes.item(i);- String name = DOMUtil.getAttr(node, "name", null);+ String name = DOMUtil.getAttr(node, CORE_NAME, null);if (origCoreName.equals(DOMUtil.substituteProperty(name,loader.getCoreProperties()))) {coreNode = node;@@ -1181,28 +1193,28 @@ public class CoreContainer}}- coreAttribs.put("name", coreName);+ coreAttribs.put(CORE_NAME, coreName);String instanceDir = dcore.getInstanceDir();- addCoreProperty(coreAttribs, coreNode, "instanceDir", instanceDir, null);+ addCoreProperty(coreAttribs, coreNode, CORE_INSTDIR, instanceDir, null);// write configString configName = dcore.getConfigName();- addCoreProperty(coreAttribs, coreNode, "conf", configName, dcore.getDefaultConfigName());+ addCoreProperty(coreAttribs, coreNode, CORE_CONFIG, configName, dcore.getDefaultConfigName());// write schemaString schema = dcore.getSchemaName();- addCoreProperty(coreAttribs, coreNode, "schema", schema, dcore.getDefaultSchemaName());+ addCoreProperty(coreAttribs, coreNode, CORE_SCHEMA, schema, dcore.getDefaultSchemaName());String dataDir = dcore.dataDir;- addCoreProperty(coreAttribs, coreNode, "dataDir", dataDir, null);+ addCoreProperty(coreAttribs, coreNode, CORE_DATADIR, dataDir, null);CloudDescriptor cd = dcore.getCloudDescriptor();String shard = null;if (cd != null) {shard = cd.getShardId();}- addCoreProperty(coreAttribs, coreNode, "shard", shard, null);+ addCoreProperty(coreAttribs, coreNode, CORE_SHARD, shard, null);String collection = null;// only write out the collection name if it's not the default (the@@ -1212,12 +1224,12 @@ public class CoreContainercollection = cd.getCollectionName();}- addCoreProperty(coreAttribs, coreNode, "collection", collection, dcore.name);+ addCoreProperty(coreAttribs, coreNode, CORE_COLLECTION, collection, dcore.name);// we don't try and preserve sys prop defs in theseString opt = dcore.getPropertiesName();if (opt != null) {- coreAttribs.put("properties", opt);+ coreAttribs.put(CORE_PROPERTIES, opt);}SolrCoreXMLDef solrCoreXMLDef = new SolrCoreXMLDef();