SOLR-863 -- SolrCore.initIndex should close the directory it gets for clearing the lock and use the DirectoryFactory

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@727719 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2008-12-18 13:18:41 +00:00
parent 39c1b9b3a5
commit c2c78750e8
2 changed files with 10 additions and 4 deletions

View File

@ -182,6 +182,9 @@ Bug Fixes
otherwise it writes fieldType.toObject. This fixes the bug with encoding/decoding UUIDField.
(koji, Noble Paul, shalin)
18. SOLR-863: SolrCore.initIndex should close the directory it gets for clearing the lock and
use the DirectoryFactory. (Mark Miller via shalin)
Other Changes
----------------------

View File

@ -360,10 +360,13 @@ 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(), solrConfig.mainIndexConfig);
if (dir != null && IndexWriter.isLocked(dir)) {
log.warn(logid+"WARNING: Solr index directory '" + getIndexDir() + "' is locked. Unlocking...");
IndexWriter.unlock(dir);
Directory dir = SolrIndexWriter.getDirectory(getIndexDir(), getDirectoryFactory(), solrConfig.mainIndexConfig);
if (dir != null) {
if (IndexWriter.isLocked(dir)) {
log.warn(logid+"WARNING: Solr index directory '" + getIndexDir() + "' is locked. Unlocking...");
IndexWriter.unlock(dir);
}
dir.close();
}
}