diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2023-02-22 21:03:22 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2023-02-22 21:03:22 +0100 |
commit | 6cc741aa233c4f27f25979bc18145551e75c5ae1 (patch) | |
tree | f3ceb1f373647f8165bcd83df87ef42dc834b838 /org.eclipse.jgit/src/org/eclipse/jgit | |
parent | 628ca9bd6f5b4ce26181aaa14d7c464c767321b6 (diff) | |
parent | b526829fba80af0dd0e4a3289ddf18a4f417da05 (diff) | |
download | jgit-6cc741aa233c4f27f25979bc18145551e75c5ae1.tar.gz jgit-6cc741aa233c4f27f25979bc18145551e75c5ae1.zip |
Merge branch 'stable-6.1' into stable-6.2
* stable-6.1:
If tryLock fails to get the lock another gc has it
Fix GcConcurrentTest#testInterruptGc
Don't swallow IOException in GC.PidLock#lock
Check if FileLock is valid before using or releasing it
Change-Id: I3ffe92566cc145053bb762f612dd96bc6d542c62
Diffstat (limited to 'org.eclipse.jgit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java | 10 |
1 files changed, 5 insertions, 5 deletions
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 080af97cbc..de01168195 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 @@ -1631,7 +1631,7 @@ public class GC { pidFile = repo.getDirectory().toPath().resolve(GC_PID); } - boolean lock() { + boolean lock() throws IOException { if (Files.exists(pidFile)) { Instant mtime = FS.DETECTED .lastModifiedInstant(pidFile.toFile()); @@ -1649,8 +1649,8 @@ public class GC { f = new RandomAccessFile(pidFile.toFile(), "rw"); //$NON-NLS-1$ channel = f.getChannel(); lock = channel.tryLock(); - if (lock == null) { - failedToLock(); + if (lock == null || !lock.isValid()) { + gcAlreadyRunning(); return false; } channel.write(ByteBuffer @@ -1670,7 +1670,7 @@ public class GC { JGitText.get().closePidLockFailed, pidFile), e1); } - return false; + throw e; } return true; } @@ -1728,7 +1728,7 @@ public class GC { public void close() { boolean wasLocked = false; try { - if (lock != null) { + if (lock != null && lock.isValid()) { lock.release(); wasLocked = true; } |