Apache Lucene open-source search software
SOLR-1962: SolrCore#initIndex should not use a mix of indexPath and newIndexPath
Mark Robert Millerb06f0b0b71b7
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txtindex c460314787e..073c1726bf2 100644--- a/solr/CHANGES.txt+++ b/solr/CHANGES.txt@@ -531,6 +531,8 @@ Bug Fixes* SOLR-2173: Suggester should always rebuild Lookup data if Lookup.load fails. (ab)* SOLR-2190: change xpath from RSS 0.9 to 1.0 in slashdot sample. (koji)++* SOLR-1962: SolrCore#initIndex should not use a mix of indexPath and newIndexPath (Mark Miller)Other Changes----------------------diff --git a/solr/src/java/org/apache/solr/core/SolrCore.java b/solr/src/java/org/apache/solr/core/SolrCore.javaindex 7e9c65c5dc3..a8f6c9684f1 100644--- a/solr/src/java/org/apache/solr/core/SolrCore.java+++ b/solr/src/java/org/apache/solr/core/SolrCore.java@@ -367,12 +367,12 @@ public final class SolrCore implements SolrInfoMBean {void initIndex() {try {-initDirectoryFactory();- boolean indexExists = getDirectoryFactory().exists(getNewIndexDir());+ String indexDir = getNewIndexDir();+ boolean indexExists = getDirectoryFactory().exists(indexDir);boolean firstTime;synchronized (SolrCore.class) {- firstTime = dirs.add(new File(getNewIndexDir()).getCanonicalPath());+ firstTime = dirs.add(new File(indexDir).getCanonicalPath());}boolean removeLocks = solrConfig.unlockOnStartup;@@ -381,10 +381,10 @@ public final class SolrCore implements SolrInfoMBean {if (indexExists && firstTime && removeLocks) {// to remove locks, the directory must already exist... so we create it// if it didn't exist already...- Directory dir = SolrIndexWriter.getDirectory(getIndexDir(), getDirectoryFactory(), solrConfig.mainIndexConfig);+ Directory dir = SolrIndexWriter.getDirectory(indexDir, getDirectoryFactory(), solrConfig.mainIndexConfig);if (dir != null) {if (IndexWriter.isLocked(dir)) {- log.warn(logid+"WARNING: Solr index directory '" + getIndexDir() + "' is locked. Unlocking...");+ log.warn(logid+"WARNING: Solr index directory '" + indexDir+ "' is locked. Unlocking...");IndexWriter.unlock(dir);}dir.close();@@ -393,10 +393,10 @@ public final class SolrCore implements SolrInfoMBean {// Create the index if it doesn't exist.if(!indexExists) {- log.warn(logid+"Solr index directory '" + new File(getNewIndexDir()) + "' doesn't exist."+ log.warn(logid+"Solr index directory '" + new File(indexDir) + "' doesn't exist."+ " Creating new index...");- SolrIndexWriter writer = new SolrIndexWriter("SolrCore.initIndex", getIndexDir(), getDirectoryFactory(), true, schema, solrConfig.mainIndexConfig, solrDelPolicy);+ SolrIndexWriter writer = new SolrIndexWriter("SolrCore.initIndex", indexDir, getDirectoryFactory(), true, schema, solrConfig.mainIndexConfig, solrDelPolicy);writer.close();}