Skip to content

Apache Lucene open-source search software

- Added public static boolean isLocked(String) method. PR: Obtained from: Submitted by: Colin Britton Reviewed by: otis

Otis Gospodnetic1ec9086829e0
diff --git a/src/java/org/apache/lucene/index/IndexReader.java b/src/java/org/apache/lucene/index/IndexReader.java
index fdbd026ef3a..b71e435f1d6 100644
--- a/src/java/org/apache/lucene/index/IndexReader.java
+++ b/src/java/org/apache/lucene/index/IndexReader.java
@@ -310,6 +310,16 @@ abstract public class IndexReader {
return directory.fileExists("write.lock");
}
+ /**
+ * Returns <code>true</code> iff the index in the named directory is
+ * currently locked.
+ * @param directory the directory to check for a lock
+ * @throws IOException if there is a problem with accessing the index
+ */
+ public static boolean isLocked(String directory) throws IOException {
+ return (new File(directory, "write.lock")).exists();
+ }
+
/**
* Forcibly unlocks the index in the named directory.
* <P>