Fix OpenSshConfigTest#config
- use FS.DETECTED instead of db.getFS() since the ssh config is typically in a different place than the repository, the same is used in OpenSshConfig - reduce unnecessary repeated writes by introducing wait for one tick of the file time resolution Change-Id: Ifac915e97ff420ec5cf8e2f162e351f9f51b6b14 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
parent
e60b9e1879
commit
5a88815b1c
|
@ -58,6 +58,7 @@
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import org.eclipse.jgit.junit.RepositoryTestCase;
|
import org.eclipse.jgit.junit.RepositoryTestCase;
|
||||||
import org.eclipse.jgit.lib.Constants;
|
import org.eclipse.jgit.lib.Constants;
|
||||||
|
@ -93,12 +94,17 @@ public void setUp() throws Exception {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void config(String data) throws IOException {
|
private void config(String data) throws IOException {
|
||||||
FS fs = db.getFS();
|
FS fs = FS.DETECTED;
|
||||||
|
long resolution = FS.getFileStoreAttributes(configFile.toPath())
|
||||||
|
.getFsTimestampResolution().toNanos();
|
||||||
Instant lastMtime = fs.lastModifiedInstant(configFile);
|
Instant lastMtime = fs.lastModifiedInstant(configFile);
|
||||||
do {
|
do {
|
||||||
try (final OutputStreamWriter fw = new OutputStreamWriter(
|
try (final OutputStreamWriter fw = new OutputStreamWriter(
|
||||||
new FileOutputStream(configFile), UTF_8)) {
|
new FileOutputStream(configFile), UTF_8)) {
|
||||||
fw.write(data);
|
fw.write(data);
|
||||||
|
TimeUnit.NANOSECONDS.sleep(resolution);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
Thread.interrupted();
|
||||||
}
|
}
|
||||||
} while (lastMtime.equals(fs.lastModifiedInstant(configFile)));
|
} while (lastMtime.equals(fs.lastModifiedInstant(configFile)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue