diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-08-11 02:43:02 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-08-16 16:51:45 +0200 |
commit | 7f92a70fb3a5b7e91e5d370098fa65f6c8f35efa (patch) | |
tree | 7f1c63551671bd8f3d178baea4e9c2618cd68c00 /org.eclipse.jgit.junit/src/org/eclipse/jgit | |
parent | fed2a8a4f9b905b6d11f90bf25f023d4ca736365 (diff) | |
download | jgit-7f92a70fb3a5b7e91e5d370098fa65f6c8f35efa.tar.gz jgit-7f92a70fb3a5b7e91e5d370098fa65f6c8f35efa.zip |
Avoid setup and saving FileStoreAttributes compete for ~/.gitconfig lock
FS determines FileStore attributes in a background thread and tries to
save the results to the global git configuration. This competed with
LocalDiskRepositoryTestCase#setup trying to save changes to the same
file requiring the same lock. This frequently led to one of the threads
failing to acquire the lock.
Fix this by first initiating determination of FileStore attributes which
then uses a MockSystemReader not using a userConfig stored to disk which
avoids this race for the lock.
Change-Id: I30fcd96bc15100f8ef9b2a9eb3320bb5ace97c67
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src/org/eclipse/jgit')
-rw-r--r-- | org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java index cce83c00b2..f8f0c18cba 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java @@ -130,6 +130,13 @@ public abstract class LocalDiskRepositoryTestCase { mockSystemReader = new MockSystemReader(); SystemReader.setInstance(mockSystemReader); + + // Measure timer resolution before the test to avoid time critical tests + // are affected by time needed for measurement. + // The MockSystemReader must be configured first since we need to use + // the same one here + FS.getFileStoreAttributes(tmp.toPath().getParent()); + mockSystemReader.userGitConfig = new FileBasedConfig(new File(tmp, "usergitconfig"), FS.DETECTED); // We have to set autoDetach to false for tests, because tests expect to be able @@ -140,12 +147,6 @@ public abstract class LocalDiskRepositoryTestCase { mockSystemReader.userGitConfig.save(); ceilTestDirectories(getCeilings()); - // Measure timer resolution before the test to avoid time critical tests - // are affected by time needed for measurement. - // The MockSystemReader must be configured first since we need to use - // the same one here - FS.getFileStoreAttributes(tmp.toPath().getParent()); - author = new PersonIdent("J. Author", "jauthor@example.com"); committer = new PersonIdent("J. Committer", "jcommitter@example.com"); |