Apache Lucene open-source search software
SOLR-1577: fix data dir default to stay under solr home
Yonik Seeleyace3e15d0de1
diff --git a/CHANGES.txt b/CHANGES.txtindex f6c8c069bd4..b9b490b51a9 100644--- a/CHANGES.txt+++ b/CHANGES.txt@@ -64,6 +64,12 @@ Bug Fixes* SOLR-1563: Binary fields, including trie-based numeric fields, caused nullpointer exceptions in the luke request handler. (yonik)+* SOLR-1577: The example solrconfig.xml defaulted to a solr data dir+ relative to the current working directory, even if a different solr home+ was being used. The new behavior changes the default to a zero length+ string, which is treated the same as if no dataDir had been specified,+ hence the "data" directory under the solr home will be used. (yonik)+Other Changes----------------------diff --git a/example/solr/conf/solrconfig.xml b/example/solr/conf/solrconfig.xmlindex a507339e1e9..fa1f8ca0430 100755--- a/example/solr/conf/solrconfig.xml+++ b/example/solr/conf/solrconfig.xml@@ -68,7 +68,7 @@<!-- Used to specify an alternate directory to hold all index dataother than the default ./data under the Solr home.If replication is in use, this should match the replication configuration. -->- <dataDir>${solr.data.dir:./solr/data}</dataDir>+ <dataDir>${solr.data.dir:}</dataDir><!-- WARNING: this <indexDefaults> section only provides defaults for index writersdiff --git a/src/java/org/apache/solr/core/CoreDescriptor.java b/src/java/org/apache/solr/core/CoreDescriptor.javaindex 86dae956714..5ad0fc9a669 100644--- a/src/java/org/apache/solr/core/CoreDescriptor.java+++ b/src/java/org/apache/solr/core/CoreDescriptor.java@@ -109,6 +109,8 @@ public class CoreDescriptor {public void setDataDir(String s) {dataDir = s;+ // normalize zero length to null.+ if (dataDir != null && dataDir.length()==0) dataDir=null;}/**@return the core instance directory. */diff --git a/src/java/org/apache/solr/core/SolrConfig.java b/src/java/org/apache/solr/core/SolrConfig.javaindex 715fdd25fc3..5b6dc9afe1c 100644--- a/src/java/org/apache/solr/core/SolrConfig.java+++ b/src/java/org/apache/solr/core/SolrConfig.java@@ -160,6 +160,7 @@ public class SolrConfig extends Config {unlockOnStartup = getBool("mainIndex/unlockOnStartup", false);useColdSearcher = getBool("query/useColdSearcher",false);dataDir = get("dataDir", null);+ if (dataDir != null && dataDir.length()==0) dataDir=null;userCacheConfigs = CacheConfig.getMultipleConfigs(this, "query/cache");