lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r948082 - in /lucene/dev/trunk/lucene: CHANGES.txt src/java/org/apache/lucene/index/IndexWriter.java
Date Tue, 25 May 2010 16:05:04 GMT
Author: mikemccand
Date: Tue May 25 16:05:03 2010
New Revision: 948082

URL: http://svn.apache.org/viewvc?rev=948082&view=rev
Log:
LUCENE-2476: release write lock on any exception during IndexWriter ctor

Modified:
    lucene/dev/trunk/lucene/CHANGES.txt
    lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java

Modified: lucene/dev/trunk/lucene/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/CHANGES.txt?rev=948082&r1=948081&r2=948082&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/CHANGES.txt (original)
+++ lucene/dev/trunk/lucene/CHANGES.txt Tue May 25 16:05:03 2010
@@ -402,6 +402,10 @@ Bug fixes
   demo resulted in ArrayIndexOutOfBoundsException.  
   (Sami Siren via Robert Muir)
 
+* LUCENE-2476: If any exception is hit init'ing IW, release the write
+  lock (previously we only released on IOException).  (Tamas Cservenak
+  via Mike McCandless)
+
 New features
 
 * LUCENE-2128: Parallelized fetching document frequencies during weight

Modified: lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java?rev=948082&r1=948081&r2=948082&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java (original)
+++ lucene/dev/trunk/lucene/src/java/org/apache/lucene/index/IndexWriter.java Tue May 25 16:05:03
2010
@@ -1110,9 +1110,12 @@ public class IndexWriter implements Clos
     }
 
     writeLock = directory.makeLock(WRITE_LOCK_NAME);
+
     if (!writeLock.obtain(writeLockTimeout)) // obtain write lock
       throw new LockObtainFailedException("Index locked for write: " + writeLock);
 
+    boolean success = false;
+
     try {
       if (create) {
         // Try to read first.  This is to allow create
@@ -1179,10 +1182,20 @@ public class IndexWriter implements Clos
         messageState();
       }
 
-    } catch (IOException e) {
-      writeLock.release();
-      writeLock = null;
-      throw e;
+      success = true;
+
+    } finally {
+      if (!success) {
+        if (infoStream != null) {
+          message("init: hit exception on init; releasing write lock");
+        }
+        try {
+          writeLock.release();
+        } catch (Throwable t) {
+          // don't mask the original exception
+        }
+        writeLock = null;
+      }
     }
   }
   



Mime
View raw message