aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2023-02-22 02:42:32 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2023-02-22 02:56:06 +0100
commita6da439b47bd2d7c3772f4a94d199894d3edaee9 (patch)
treeb07d97d84eb74b3ae040517b4877974ccccc06a9
parent8eee800fb1853a9b73067fa875737bb3a117ec2c (diff)
downloadjgit-a6da439b47bd2d7c3772f4a94d199894d3edaee9.tar.gz
jgit-a6da439b47bd2d7c3772f4a94d199894d3edaee9.zip
Check if FileLock is valid before using or releasing it
Change-Id: I23ba67b61b9b03772f33a929c080c0d02b8c8652
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java4
1 files changed, 2 insertions, 2 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 3f281a5d6c..04c8418f6d 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 @@ public class GC {
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 @@ public class GC {
public void close() {
boolean wasLocked = false;
try {
- if (lock != null) {
+ if (lock != null && lock.isValid()) {
lock.release();
wasLocked = true;
}