]> source.dussan.org Git - jgit.git/commitdiff
Check if FileLock is valid before using or releasing it 71/200071/2
authorMatthias Sohn <matthias.sohn@sap.com>
Wed, 22 Feb 2023 01:42:32 +0000 (02:42 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Wed, 22 Feb 2023 01:56:06 +0000 (02:56 +0100)
Change-Id: I23ba67b61b9b03772f33a929c080c0d02b8c8652

org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/GC.java

index 3f281a5d6cafcd3bcc51c4589dc3ddb2f1dc28ea..04c8418f6df46a939e8053a547c39d4eda5672ef 100644 (file)
@@ -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;
                                }