diff options
author | James Z.M. Gao <gzm55@hotmail.com> | 2022-04-08 00:29:39 +0800 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2022-05-27 01:20:16 +0200 |
commit | d67ac798f10254d038c49244e7f1e2323afdfdfc (patch) | |
tree | e8eeed169fdb538e18558ab728d434be137be8f3 /org.eclipse.jgit.test | |
parent | 78c9b9260a5287d09c87b407e396021590714513 (diff) | |
download | jgit-d67ac798f10254d038c49244e7f1e2323afdfdfc.tar.gz jgit-d67ac798f10254d038c49244e7f1e2323afdfdfc.zip |
Remove stray files (probes or lock files) created by background threads
NOTE: port back from master branch.
On process exit, it was possible that the filesystem timestamp
resolution measurement left behind .probe files or even a lock file
for the jgit.config.
Ensure the SAVE_RUNNER is shut down when the process exits (via
System.exit() or otherwise). Move lf.lock() into the try-finally
block when saving the config file.
Delete .probe files on JVM shutdown -- they are created in daemon
threads that may terminate abruptly, not executing the "finally"
clause that normally removes these files.
Bug: 579445
Change-Id: Iaee2301eb14e6201406398a90228ad10cfea6098
Diffstat (limited to 'org.eclipse.jgit.test')
-rw-r--r-- | org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java index 509935dfb9..7eab1dcb09 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/internal/storage/file/LockFileTest.java @@ -200,4 +200,16 @@ public class LockFileTest extends RepositoryTestCase { assertFalse(lock.isLocked()); checkFile(f, "contentother"); } + + @Test + public void testUnlockNoop() throws Exception { + File f = writeTrashFile("somefile", "content"); + try { + LockFile lock = new LockFile(f); + lock.unlock(); + lock.unlock(); + } catch (Throwable e) { + fail("unlock should be noop if not locked at all."); + } + } } |