aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-02-22 21:02:09 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2023-02-22 21:02:09 +0100
commit238f1693f7eab78505d469ae6349b262aa58eade (patch)
tree768cc613e53405a619597b29eed7cdda7259946c /org.eclipse.jgit
parent2a2a208fa1651e0558755c4804a2a9db1433a345 (diff)
parentd9f75e8bb2af7307ce1d6e0a7376eb5ebe583ae4 (diff)
downloadjgit-238f1693f7eab78505d469ae6349b262aa58eade.tar.gz
jgit-238f1693f7eab78505d469ae6349b262aa58eade.zip
Merge branch 'stable-5.13' into stable-6.0
* stable-5.13: 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: I708d0936fa86b028e4da4e7e21f332f8b48ad293
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java10
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;
}