]> source.dussan.org Git - jgit.git/commitdiff
When renaming the lock file succeeds the lock isn't held anymore 98/11498/1
authorMatthias Sohn <matthias.sohn@sap.com>
Tue, 26 Mar 2013 20:20:19 +0000 (21:20 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 26 Mar 2013 20:26:07 +0000 (21:26 +0100)
This wrong book-keeping caused IOExceptions to be thrown because
LockFile.unlock() erroneously tried to delete the non-existing lock
file. These IOExeptions were hidden since they were silently caught.

Change-Id: If42b6192d92c5a2d8f2bf904b16567ef08c32e89
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java

index 625ec343fd6b2ce653976b3f0caffb3d38065b45..06eb42cbbce4699f4de8f825b238eb958ed1729c 100644 (file)
@@ -437,11 +437,16 @@ public class LockFile {
                }
 
                saveStatInformation();
-               if (lck.renameTo(ref))
+               if (lck.renameTo(ref)) {
+                       haveLck = false;
                        return true;
-               if (!ref.exists() || deleteRef())
-                       if (renameLock())
+               }
+               if (!ref.exists() || deleteRef()) {
+                       if (renameLock()) {
+                               haveLck = false;
                                return true;
+                       }
+               }
                unlock();
                return false;
        }