summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Sohn <matthias.sohn@sap.com>2019-08-05 18:00:35 +0200
committerMatthias Sohn <matthias.sohn@sap.com>2019-08-07 13:21:39 +0200
commit3b368d5578db13b52b2485b11bf3da1e24ccffd2 (patch)
tree64b481fb7683179b49af7b9c13e5c57745b94720
parent6857138e19ec6f597609339c3c88d58fb4dd0c0a (diff)
downloadjgit-3b368d5578db13b52b2485b11bf3da1e24ccffd2.tar.gz
jgit-3b368d5578db13b52b2485b11bf3da1e24ccffd2.zip
In LockFile#waitForStatChange wait in units of file time resolution
Since we now measure file time resolution we can use it to replace the hard coded wait time of 25ms. FileSnapshot#equals will return true until the mtime of the old (o) and the new FileSnapshot (n) differ by at least one file time resolution. Change-Id: Icb713a80ce9eb929242ed083406bfb6650c72223 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java5
1 files changed, 4 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
index ccca0279aa..420e737543 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/internal/storage/file/LockFile.java
@@ -61,6 +61,7 @@ import java.nio.file.StandardCopyOption;
import java.nio.file.attribute.FileTime;
import java.text.MessageFormat;
import java.time.Instant;
+import java.util.concurrent.TimeUnit;
import org.eclipse.jgit.internal.JGitText;
import org.eclipse.jgit.lib.Constants;
@@ -425,8 +426,10 @@ public class LockFile {
public void waitForStatChange() throws InterruptedException {
FileSnapshot o = FileSnapshot.save(ref);
FileSnapshot n = FileSnapshot.save(lck);
+ long fsTimeResolution = FS.getFileStoreAttributes(lck.toPath())
+ .getFsTimestampResolution().toNanos();
while (o.equals(n)) {
- Thread.sleep(25 /* milliseconds */);
+ TimeUnit.NANOSECONDS.sleep(fsTimeResolution);
try {
Files.setLastModifiedTime(lck.toPath(),
FileTime.from(Instant.now()));