mirror of https://github.com/apache/lucene.git
LUCENE-1050 and LUCENE-1138 fixes for lock problem
git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@612868 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0a54ca1920
commit
ed9fdba601
|
@ -284,7 +284,9 @@ public class SpellChecker {
|
|||
* @throws IOException
|
||||
*/
|
||||
public void clearIndex() throws IOException {
|
||||
IndexReader.unlock(spellIndex);
|
||||
if (IndexReader.isLocked(spellIndex)){
|
||||
IndexReader.unlock(spellIndex);
|
||||
}
|
||||
IndexWriter writer = new IndexWriter(spellIndex, null, true);
|
||||
writer.close();
|
||||
}
|
||||
|
@ -308,7 +310,9 @@ public class SpellChecker {
|
|||
* @throws IOException
|
||||
*/
|
||||
public void indexDictionary(Dictionary dict) throws IOException {
|
||||
IndexReader.unlock(spellIndex);
|
||||
if (IndexReader.isLocked(spellIndex)){
|
||||
IndexReader.unlock(spellIndex);
|
||||
}
|
||||
IndexWriter writer = new IndexWriter(spellIndex, new WhitespaceAnalyzer(),
|
||||
!IndexReader.indexExists(spellIndex));
|
||||
writer.setMergeFactor(300);
|
||||
|
|
|
@ -145,7 +145,7 @@ class SimpleFSLock extends Lock {
|
|||
}
|
||||
|
||||
public void release() throws LockReleaseFailedException {
|
||||
if (!lockFile.delete())
|
||||
if (lockFile.exists() && !lockFile.delete())
|
||||
throw new LockReleaseFailedException("failed to delete " + lockFile);
|
||||
}
|
||||
|
||||
|
|
|
@ -190,9 +190,9 @@ public class TestLockFactory extends LuceneTestCase {
|
|||
if (writer2 != null) {
|
||||
try {
|
||||
writer2.close();
|
||||
fail("writer2.close() should have hit LockReleaseFailedException");
|
||||
} catch (LockReleaseFailedException e) {
|
||||
// expected
|
||||
} catch (LockReleaseFailedException e) {
|
||||
fail("writer2.close() should not have hit LockReleaseFailedException");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue