Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-1577: fix data dir default to stay under solr home

Yonik Seeleyace3e15d0de1
diff --git a/CHANGES.txt b/CHANGES.txt
index 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 null
pointer 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.xml
index 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 data
other 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 writers
diff --git a/src/java/org/apache/solr/core/CoreDescriptor.java b/src/java/org/apache/solr/core/CoreDescriptor.java
index 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.java
index 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");