From c2c78750e82406bb8c8aaf8103c156ccfdfcf6b9 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Thu, 18 Dec 2008 13:18:41 +0000 Subject: [PATCH] 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 --- CHANGES.txt | 3 +++ src/java/org/apache/solr/core/SolrCore.java | 11 +++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index 56fe7a872b8..13d8f25be5b 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -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 ---------------------- diff --git a/src/java/org/apache/solr/core/SolrCore.java b/src/java/org/apache/solr/core/SolrCore.java index 4b4804910d7..5f2e9b23e16 100644 --- a/src/java/org/apache/solr/core/SolrCore.java +++ b/src/java/org/apache/solr/core/SolrCore.java @@ -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(); } }