Skip to main content
diff options
authorMatthias Sohn2019-08-08 06:30:47 -0400
committerMatthias Sohn2019-08-08 07:04:38 -0400
commit718555518ded4fbcafe0c1203f0035d3251884e6 (patch)
tree3e49529cd0ebc21fcea581efe0fa15fdcdc8b81c /org.eclipse.jgit.http.server/src/org
parentfcfe1299c37ae8308e9d930201823b3ac340dd2b (diff)
parent0046b2a8fefcbfecc10a7b198a075eb2775d3e7a (diff)
Merge branch 'stable-5.2' into stable-5.3
* stable-5.2: Fix OpenSshConfigTest#config FileSnapshot: fix bug with timestamp thresholding In LockFile#waitForStatChange wait in units of file time resolution Cache FileStoreAttributeCache per directory Fix FileSnapshot#save(long) and FileSnapshot#save(Instant) Persist minimal racy threshold and allow manual configuration Measure minimum racy interval to auto-configure FileSnapshot Reuse FileUtils to recursively delete files created by tests Fix FileAttributeCache.toString() Add test for racy git detection in FileSnapshot Repeat RefDirectoryTest.testGetRef_DiscoversModifiedLoose 100 times Fix org.eclipse.jdt.core.prefs of org.eclipse.jgit.junit Add missing javadoc in org.eclipse.jgit.junit Enhance RepeatRule to report number of failures at the end Fix FileSnapshotTests for filesystem with high timestamp resolution Retry deleting test files in FileBasedConfigTest Measure filesystem timestamp resolution already in test setup Refactor FileSnapshotTest to use NIO APIs Measure stored timestamp resolution instead of time to touch file Handle CancellationException in FileStoreAttributeCache Fix FileSnapshot#saveNoConfig Use Instant for smudge time in DirCache and DirCacheEntry Use Instant instead of milliseconds for filesystem timestamp handling Workaround SecurityException in FS#getFsTimestampResolution Fix NPE in FS$FileStoreAttributeCache.getFsTimestampResolution FS: ignore AccessDeniedException when measuring timestamp resolution Add debug trace for FileSnapshot Use to touch file and set mtime to now Persist filesystem timestamp resolution and allow manual configuration Increase bazel timeout for long running tests Bazel: Fix lint warning flagged by buildifier Update bazlets to latest version Bazel: Add missing dependencies for ArchiveCommandTest Bazel: Remove FileTreeIteratorWithTimeControl from BUILD file Add support for nanoseconds and microseconds for Config#getTimeUnit Optionally measure filesystem timestamp resolution asynchronously Delete unused FileTreeIteratorWithTimeControl FileSnapshot#equals: consider UNKNOWN_SIZE Timeout measuring file timestamp resolution after 2 seconds Fix RacyGitTests#testRacyGitDetection Change RacyGitTests to create a racy git situation in a stable way Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8 Fix non-deterministic hash of archives created by ArchiveCommand Update Maven plugins ecj, plexus, error-prone Update Maven plugins and cleanup Maven warnings Make inner classes static where possible Fix API problem filters Change-Id: I238adfd3080a5fed9d64c3c757297da6ea893918 Signed-off-by: Matthias Sohn <>
Diffstat (limited to 'org.eclipse.jgit.http.server/src/org')
2 files changed, 12 insertions, 5 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/
index 05510a05b0..946fb15a3d 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/
@@ -58,12 +58,14 @@ import;
import java.text.MessageFormat;
+import java.time.Instant;
import java.util.Enumeration;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.jgit.lib.ObjectId;
+import org.eclipse.jgit.util.FS;
* Dumps a file over HTTP GET (or its information via HEAD).
@@ -76,7 +78,7 @@ final class FileSender {
private final RandomAccessFile source;
- private final long lastModified;
+ private final Instant lastModified;
private final long fileLen;
@@ -89,7 +91,7 @@ final class FileSender {
this.source = new RandomAccessFile(path, "r");
try {
- this.lastModified = path.lastModified();
+ this.lastModified = FS.DETECTED.lastModifiedInstant(path);
this.fileLen = source.getChannel().size();
this.end = fileLen;
} catch (IOException e) {
@@ -114,7 +116,7 @@ final class FileSender {
- long getLastModified() {
+ Instant getLastModified() {
return lastModified;
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/
index 62f075c73c..5a27be6430 100644
--- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/
+++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/
@@ -54,6 +54,7 @@ import static org.eclipse.jgit.util.HttpSupport.HDR_LAST_MODIFIED;
+import java.time.Instant;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
@@ -76,7 +77,9 @@ abstract class ObjectFileServlet extends HttpServlet {
String etag(FileSender sender) throws IOException {
- return Long.toHexString(sender.getLastModified());
+ Instant lastModified = sender.getLastModified();
+ return Long.toHexString(lastModified.getEpochSecond())
+ + Long.toHexString(lastModified.getNano());
@@ -145,7 +148,9 @@ abstract class ObjectFileServlet extends HttpServlet {
try {
final String etag = etag(sender);
- final long lastModified = (sender.getLastModified() / 1000) * 1000;
+ // HTTP header Last-Modified header has a resolution of 1 sec, see
+ //
+ final long lastModified = sender.getLastModified().getEpochSecond();
String ifNoneMatch = req.getHeader(HDR_IF_NONE_MATCH);
if (etag != null && etag.equals(ifNoneMatch)) {

Back to the top