diff options
author | Jens Baumgart <jens.baumgart@sap.com> | 2010-07-26 10:18:47 +0200 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-07-27 10:00:47 -0700 |
commit | db82b8d7eb646a2d31f1b4e52ab4a623743192e9 (patch) | |
tree | d484fb29139ae3673dfad6930aaefb467ec41977 /org.eclipse.jgit.junit/src/org/eclipse | |
parent | a00377a7e23dbde315598ee20f61c45d031e159a (diff) | |
download | jgit-db82b8d7eb646a2d31f1b4e52ab4a623743192e9.tar.gz jgit-db82b8d7eb646a2d31f1b4e52ab4a623743192e9.zip |
Fix concurrent read / write issue in LockFile on Windows
LockFile.commit fails if another thread concurrently reads
the base file. The problem is fixed by retrying the rename
operation if it fails.
Change-Id: I6bb76ea7f2e6e90e3ddc45f9dd4d69bd1b6fa1eb
Bug: 308506
Signed-off-by: Jens Baumgart <jens.baumgart@sap.com>
Diffstat (limited to 'org.eclipse.jgit.junit/src/org/eclipse')
3 files changed, 4 insertions, 3 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 2b82d82d74..47956e5127 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 @@ -69,6 +69,7 @@ import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.storage.file.FileRepository; import org.eclipse.jgit.storage.file.WindowCache; import org.eclipse.jgit.storage.file.WindowCacheConfig; +import org.eclipse.jgit.util.FS; import org.eclipse.jgit.util.IO; import org.eclipse.jgit.util.SystemReader; @@ -128,7 +129,7 @@ public abstract class LocalDiskRepositoryTestCase extends TestCase { mockSystemReader = new MockSystemReader(); mockSystemReader.userGitConfig = new FileBasedConfig(new File(trash, - "usergitconfig")); + "usergitconfig"), FS.DETECTED); ceilTestDirectories(getCeilings()); SystemReader.setInstance(mockSystemReader); diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java index eb08417bc8..5c2e77f673 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/MockSystemReader.java @@ -67,7 +67,7 @@ public class MockSystemReader extends SystemReader { init(Constants.GIT_AUTHOR_EMAIL_KEY); init(Constants.GIT_COMMITTER_NAME_KEY); init(Constants.GIT_COMMITTER_EMAIL_KEY); - userGitConfig = new FileBasedConfig(null) { + userGitConfig = new FileBasedConfig(null, null) { @Override public void load() throws IOException, ConfigInvalidException { // Do nothing diff --git a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java index 3c58271257..afe1c0bc63 100644 --- a/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java +++ b/org.eclipse.jgit.junit/src/org/eclipse/jgit/junit/TestRepository.java @@ -654,7 +654,7 @@ public class TestRepository<R extends Repository> { private void writeFile(final File p, final byte[] bin) throws IOException, ObjectWritingException { - final LockFile lck = new LockFile(p); + final LockFile lck = new LockFile(p, db.getFS()); if (!lck.lock()) throw new ObjectWritingException("Can't write " + p); try { |