diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java index 3f281a5d6..04c8418f6 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java @@ -1649,7 +1649,7 @@ boolean lock() { f = new RandomAccessFile(pidFile.toFile(), "rw"); //$NON-NLS-1$ channel = f.getChannel(); lock = channel.tryLock(); - if (lock == null) { + if (lock == null || !lock.isValid()) { failedToLock(); return false; } @@ -1738,7 +1738,7 @@ private String getHostName() { public void close() { boolean wasLocked = false; try { - if (lock != null) { + if (lock != null && lock.isValid()) { lock.release(); wasLocked = true; }