Browse Source

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>
tags/v5.1.9.201908210455-r
Matthias Sohn 4 years ago
parent
commit
7f92a70fb3

+ 7
- 6
org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/LocalDiskRepositoryTestCase.java View File

@@ -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");


Loading…
Cancel
Save