lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sh...@apache.org
Subject svn commit: r961612 - /lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/NativeFSLockFactory.java
Date Thu, 08 Jul 2010 07:35:19 GMT
Author: shaie
Date: Thu Jul  8 07:35:18 2010
New Revision: 961612

URL: http://svn.apache.org/viewvc?rev=961612&view=rev
Log:
LUCENE-2421: fix clearLock to not fail on file deletion

Modified:
    lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/NativeFSLockFactory.java

Modified: lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/NativeFSLockFactory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/NativeFSLockFactory.java?rev=961612&r1=961611&r2=961612&view=diff
==============================================================================
--- lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/NativeFSLockFactory.java
(original)
+++ lucene/dev/branches/branch_3x/lucene/src/java/org/apache/lucene/store/NativeFSLockFactory.java
Thu Jul  8 07:35:18 2010
@@ -152,13 +152,20 @@ public class NativeFSLockFactory extends
     // they are locked, but, still do this in case people
     // really want to see the files go away:
     if (lockDir.exists()) {
+      
+      // Try to release the lock first - if it's held by another process, this
+      // method should not silently fail.
+      // NOTE: makeLock fixes the lock name by prefixing it w/ lockPrefix.
+      // Therefore it should be called before the code block next which prefixes
+      // the given name.
+      makeLock(lockName).release();
+
       if (lockPrefix != null) {
         lockName = lockPrefix + "-" + lockName;
       }
-      File lockFile = new File(lockDir, lockName);
-      if (lockFile.exists() && !lockFile.delete()) {
-        throw new IOException("Cannot delete " + lockFile);
-      }
+      
+      // As mentioned above, we don't care if the deletion of the file failed.
+      new File(lockDir, lockName).delete();
     }
   }
 }



Mime
View raw message