LUCENE-2421: merge 3x to trunk

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@961618 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2010-07-08 07:55:32 +00:00
parent 0d31aa07b3
commit 662059f219
1 changed files with 11 additions and 4 deletions

View File

@ -152,13 +152,20 @@ public class NativeFSLockFactory extends FSLockFactory {
// 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();
}
}
}