diff options
author | James Z.M. Gao <gzm55@hotmail.com> | 2022-04-08 00:29:39 +0800 |
---|---|---|
committer | Thomas Wolf <thomas.wolf@paranor.ch> | 2022-05-15 19:41:24 +0200 |
commit | 88d5f51e61f7f90b4f760261f07c95d8dd3d7299 (patch) | |
tree | ace96beb2f068c2fb132e578f1fa6e702416eb0c /org.eclipse.jgit.test/tst/org/eclipse | |
parent | 114325560a0c01865082213092ce0ed54b6f0339 (diff) | |
download | jgit-88d5f51e61f7f90b4f760261f07c95d8dd3d7299.tar.gz jgit-88d5f51e61f7f90b4f760261f07c95d8dd3d7299.zip |
Remove stray files (probes or lock files) created by background threads
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: Ie27aca1fdaddfa487ebe072c3913d78355910df8
Diffstat (limited to 'org.eclipse.jgit.test/tst/org/eclipse')
-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."); + } + } } |