summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Halstrick <christian.halstrick@sap.com>2011-03-30 17:29:10 +0200
committerChristian Halstrick <christian.halstrick@sap.com>2011-04-02 02:20:58 +0200
commitd8bcc84154f2f34ddb8662e7b32daa83fcde45a9 (patch)
treeb86faa4cf1fa708833ab9e83ef0ae6421a07adc6
parentc261b28f677fdc755b86d16abebd2c30093514b4 (diff)
downloadjgit-d8bcc84154f2f34ddb8662e7b32daa83fcde45a9.tar.gz
jgit-d8bcc84154f2f34ddb8662e7b32daa83fcde45a9.zip
Let LockFile.unlock use FileUtils.delete()
We sometimes face the problem that the file .git/index.lock can't deleted causing JGit operations to fail. Problem is that LockFile.unlock() simply deletes the lockfile and ignores the return value of File.delete(). Instead use FileUtils.delete() with retry option. This method will retry the deletion of the file at most 10 times with sleeps inbetween. Bug: 335959 Change-Id: I9598edea9f2304fe12e6f470301211b503434848 Signed-off-by: Christian Halstrick <christian.halstrick@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java
index 6acd7132ad..08dfd7e19b 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/storage/file/LockFile.java
@@ -488,7 +488,11 @@ public class LockFile {
if (haveLck) {
haveLck = false;
- lck.delete();
+ try {
+ FileUtils.delete(lck, FileUtils.RETRY);
+ } catch (IOException e) {
+ // couldn't delete the file even after retry.
+ }
}
}