Apache Lucene open-source search software
- Fixed a bug with usage of IndexWriter.*_LOCK_NAME constants.
Otis Gospodnetic3fd7ec26792b
diff --git a/src/java/org/apache/lucene/index/IndexReader.java b/src/java/org/apache/lucene/index/IndexReader.javaindex 3505fc6e2b8..280183ae19d 100644--- a/src/java/org/apache/lucene/index/IndexReader.java+++ b/src/java/org/apache/lucene/index/IndexReader.java@@ -108,7 +108,7 @@ public abstract class IndexReader {public static IndexReader open(final Directory directory) throws IOException{synchronized (directory) { // in- & inter-process syncreturn (IndexReader)new Lock.With(- directory.makeLock("IndexWriter.COMMIT_LOCK_NAME"),+ directory.makeLock(IndexWriter.COMMIT_LOCK_NAME),IndexWriter.COMMIT_LOCK_TIMEOUT) {public Object doBody() throws IOException {IndexReader result = null;@@ -269,7 +269,7 @@ public abstract class IndexReader {*/public final synchronized void delete(int docNum) throws IOException {if (writeLock == null) {- Lock writeLock = directory.makeLock("IndexWriter.WRITE_LOCK_NAME");+ Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);if (!writeLock.obtain(IndexWriter.WRITE_LOCK_TIMEOUT)) // obtain write lockthrow new IOException("Index locked for write: " + writeLock);this.writeLock = writeLock;@@ -360,8 +360,8 @@ public abstract class IndexReader {*/public static boolean isLocked(Directory directory) throws IOException {return- directory.makeLock("IndexWriter.WRITE_LOCK_NAME").isLocked() ||- directory.makeLock("IndexWriter.COMMIT_LOCK_NAME").isLocked();+ directory.makeLock(IndexWriter.WRITE_LOCK_NAME).isLocked() ||+ directory.makeLock(IndexWriter.COMMIT_LOCK_NAME).isLocked();}@@ -383,7 +383,7 @@ public abstract class IndexReader {* currently accessing this index.*/public static void unlock(Directory directory) throws IOException {- directory.makeLock("IndexWriter.WRITE_LOCK_NAME").release();- directory.makeLock("IndexWriter.COMMIT_LOCK_NAME").release();+ directory.makeLock(IndexWriter.WRITE_LOCK_NAME).release();+ directory.makeLock(IndexWriter.COMMIT_LOCK_NAME).release();}}diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.javaindex 1af9fad294b..a0137bfe023 100644--- a/src/java/org/apache/lucene/index/IndexWriter.java+++ b/src/java/org/apache/lucene/index/IndexWriter.java@@ -169,13 +169,13 @@ public class IndexWriter {directory = d;analyzer = a;- Lock writeLock = directory.makeLock("IndexWriter.WRITE_LOCK_NAME");+ Lock writeLock = directory.makeLock(IndexWriter.WRITE_LOCK_NAME);if (!writeLock.obtain(WRITE_LOCK_TIMEOUT)) // obtain write lockthrow new IOException("Index locked for write: " + writeLock);this.writeLock = writeLock; // save itsynchronized (directory) { // in- & inter-process sync- new Lock.With(directory.makeLock("COMMIT_LOCK_NAME"), COMMIT_LOCK_TIMEOUT) {+ new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT) {public Object doBody() throws IOException {if (create)segmentInfos.write(directory);@@ -398,7 +398,7 @@ public class IndexWriter {directory));synchronized (directory) { // in- & inter-process sync- new Lock.With(directory.makeLock("COMMIT_LOCK_NAME"), COMMIT_LOCK_TIMEOUT) {+ new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME), COMMIT_LOCK_TIMEOUT) {public Object doBody() throws IOException {segmentInfos.write(directory); // commit before deletingdeleteSegments(segmentsToDelete); // delete now-unused segmentsdiff --git a/src/java/org/apache/lucene/index/SegmentReader.java b/src/java/org/apache/lucene/index/SegmentReader.javaindex 88b496811a8..a1590325157 100644--- a/src/java/org/apache/lucene/index/SegmentReader.java+++ b/src/java/org/apache/lucene/index/SegmentReader.java@@ -137,7 +137,7 @@ final class SegmentReader extends IndexReader {final synchronized void doClose() throws IOException {if (deletedDocsDirty) {synchronized (directory) { // in- & inter-process sync- new Lock.With(directory.makeLock("IndexWriter.COMMIT_LOCK_NAME"),+ new Lock.With(directory.makeLock(IndexWriter.COMMIT_LOCK_NAME),IndexWriter.COMMIT_LOCK_TIMEOUT) {public Object doBody() throws IOException {deletedDocs.write(directory, segment + ".tmp");