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.iplog/src | |
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.iplog/src')
-rw-r--r-- | org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java index 2799a4a30b..372469da04 100644 --- a/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java +++ b/org.eclipse.jgit.iplog/src/org/eclipse/jgit/iplog/IpLogMeta.java @@ -61,6 +61,7 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.storage.file.FileBasedConfig; import org.eclipse.jgit.storage.file.LockFile; +import org.eclipse.jgit.util.FS; /** * Manages the {@code .eclipse_iplog} file in a project. @@ -167,6 +168,9 @@ public class IpLogMeta { * * @param file * local file to update with current CQ records. + * @param fs + * the file system abstraction which will be necessary to perform + * certain file system operations. * @param base * base https:// URL of the IPzilla server. * @param username @@ -181,16 +185,16 @@ public class IpLogMeta { * the local file cannot be read, as it is not a valid * configuration file format. */ - public void syncCQs(File file, URL base, String username, String password) - throws IOException, ConfigInvalidException { + public void syncCQs(File file, FS fs, URL base, String username, + String password) throws IOException, ConfigInvalidException { if (!file.getParentFile().exists()) file.getParentFile().mkdirs(); - LockFile lf = new LockFile(file); + LockFile lf = new LockFile(file, fs); if (!lf.lock()) throw new IOException(MessageFormat.format(IpLogText.get().cannotLock, file)); try { - FileBasedConfig cfg = new FileBasedConfig(file); + FileBasedConfig cfg = new FileBasedConfig(file, fs); cfg.load(); loadFrom(cfg); |