From b06f0b0b71b7e2769c08abfd3d12357631bc75f4 Mon Sep 17 00:00:00 2001 From: Mark Robert Miller Date: Mon, 25 Oct 2010 18:35:31 +0000 Subject: [PATCH] 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 --- solr/CHANGES.txt | 2 ++ solr/src/java/org/apache/solr/core/SolrCore.java | 14 +++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 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.java index 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(); }