Skip to content

Apache Lucene open-source search software

LUCENE-2663: don't try to clear prior lock in IndexWriter when create=true

Michael McCandlessb83a464b9b35
diff --git a/lucene/CHANGES.txt b/lucene/CHANGES.txt
index e8caf256291..3cb37d6379e 100644
--- a/lucene/CHANGES.txt
+++ b/lucene/CHANGES.txt
@@ -132,6 +132,13 @@ Changes in Runtime Behavior
changed to enable unmapping by default if supported by the JRE.
(Mike McCandless, Uwe Schindler, Robert Muir)
+* LUCENE-2663: IndexWriter no longer forcefully clears any existing
+ locks when create=true. This was a holdover from when
+ SimpleFSLockFactory was the default locking implementation, and,
+ even then it was dangerous since it could mask bugs in IndexWriter's
+ usage, allowing applications to accidentally open two writers on the
+ same directory. (Mike McCandless)
+
API Changes
* LUCENE-2302, LUCENE-1458, LUCENE-2111, LUCENE-2514: Terms are no longer
diff --git a/lucene/src/java/org/apache/lucene/index/IndexWriter.java b/lucene/src/java/org/apache/lucene/index/IndexWriter.java
index 0eb1760b1cd..8bdd6fb9630 100644
--- a/lucene/src/java/org/apache/lucene/index/IndexWriter.java
+++ b/lucene/src/java/org/apache/lucene/index/IndexWriter.java
@@ -1073,11 +1073,6 @@ public class IndexWriter implements Closeable {
create = !IndexReader.indexExists(directory);
}
- if (create) {
- // Clear the write lock in case it's leftover:
- directory.clearLock(WRITE_LOCK_NAME);
- }
-
writeLock = directory.makeLock(WRITE_LOCK_NAME);
if (!writeLock.obtain(writeLockTimeout)) // obtain write lock