From db82b8d7eb646a2d31f1b4e52ab4a623743192e9 Mon Sep 17 00:00:00 2001 From: Jens Baumgart Date: Mon, 26 Jul 2010 10:18:47 +0200 Subject: 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 --- .../src/org/eclipse/jgit/iplog/IpLogMeta.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'org.eclipse.jgit.iplog') 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); -- cgit v1.2.3