You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jackrabbit.apache.org by mr...@apache.org on 2005/02/17 16:02:48 UTC

svn commit: r154158 - incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java

Author: mreutegg
Date: Thu Feb 17 07:02:45 2005
New Revision: 154158

URL: http://svn.apache.org/viewcvs?view=rev&rev=154158
Log:
Changed query handler to remove a possible write.lock on startup.

Modified:
    incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java

Modified: incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java
URL: http://svn.apache.org/viewcvs/incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java?view=diff&r1=154157&r2=154158
==============================================================================
--- incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java (original)
+++ incubator/jackrabbit/trunk/src/java/org/apache/jackrabbit/core/search/lucene/SearchIndex.java Thu Feb 17 07:02:45 2005
@@ -51,6 +51,9 @@
 
     private static final Logger log = Logger.getLogger(SearchIndex.class);
 
+    /** Name of the write lock file */
+    private static final String WRITE_LOCK = "write.lock";
+
     /** Name of the file to persist search internal namespace mappings */
     private static final String NS_MAPPING_FILE = "ns_mappings.properties";
 
@@ -84,9 +87,19 @@
      * @throws IOException if an error occurs while initializing this handler.
      */
     protected void doInit() throws IOException {
-        boolean create;
         try {
-            create = !getFileSystem().exists("segments");
+            // check if index is locked, probably from an unclean repository
+            // shutdown
+            if (getFileSystem().exists(WRITE_LOCK)) {
+                log.warn("Removing write lock on search index.");
+                try {
+                    getFileSystem().deleteFile(WRITE_LOCK);
+                } catch (FileSystemException e) {
+                    log.error("Unable to remove write lock on search index.");
+                }
+            }
+
+            boolean create = !getFileSystem().exists("segments");
             persistentIndex = new PersistentIndex(getFileSystem(), create, analyzer);
             persistentIndex.setUseCompoundFile(true);
             FileSystemResource mapFile = new FileSystemResource(getFileSystem(), NS_MAPPING_FILE);