SOLR-1962: SolrCore#initIndex should not use a mix of indexPath and newIndexPath

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1027229 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Mark Robert Miller 2010-10-25 18:35:31 +00:00
parent d2263013e9
commit b06f0b0b71
2 changed files with 9 additions and 7 deletions

View File

@ -531,6 +531,8 @@ Bug Fixes
* SOLR-2173: Suggester should always rebuild Lookup data if Lookup.load fails. (ab) * 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-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 Other Changes
---------------------- ----------------------

View File

@ -367,12 +367,12 @@ public final class SolrCore implements SolrInfoMBean {
void initIndex() { void initIndex() {
try { try {
initDirectoryFactory(); initDirectoryFactory();
boolean indexExists = getDirectoryFactory().exists(getNewIndexDir()); String indexDir = getNewIndexDir();
boolean indexExists = getDirectoryFactory().exists(indexDir);
boolean firstTime; boolean firstTime;
synchronized (SolrCore.class) { synchronized (SolrCore.class) {
firstTime = dirs.add(new File(getNewIndexDir()).getCanonicalPath()); firstTime = dirs.add(new File(indexDir).getCanonicalPath());
} }
boolean removeLocks = solrConfig.unlockOnStartup; boolean removeLocks = solrConfig.unlockOnStartup;
@ -381,10 +381,10 @@ public final class SolrCore implements SolrInfoMBean {
if (indexExists && firstTime && removeLocks) { if (indexExists && firstTime && removeLocks) {
// to remove locks, the directory must already exist... so we create it // to remove locks, the directory must already exist... so we create it
// if it didn't exist already... // 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 (dir != null) {
if (IndexWriter.isLocked(dir)) { 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); IndexWriter.unlock(dir);
} }
dir.close(); dir.close();
@ -393,10 +393,10 @@ public final class SolrCore implements SolrInfoMBean {
// Create the index if it doesn't exist. // Create the index if it doesn't exist.
if(!indexExists) { 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..."); + " 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(); writer.close();
} }