diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2019-08-09 14:12:57 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2019-08-09 14:32:02 +0200 |
commit | 3cea3676c75127dd720ea4c0b86d92ed040f7fa7 (patch) | |
tree | 21d51403e56b21af1dc5052e98232ecb926c425d /org.eclipse.jgit.http.server/src | |
parent | 86be1b4038581ed6cc94ff1f7a7c3652b0e0b767 (diff) | |
parent | a65e7c75016b72300a02119a6d6d089bafb5b4f7 (diff) | |
download | jgit-3cea3676c75127dd720ea4c0b86d92ed040f7fa7.tar.gz jgit-3cea3676c75127dd720ea4c0b86d92ed040f7fa7.zip |
Merge branch 'stable-5.4'
* stable-5.4: (82 commits)
Export all packages of o.e.j.ant and o.e.j.archive bundles
Do not require test bundles to export all packages
Fix API problem filters
Increase severity of AmbiguousMethodReference to ERROR
[error prone] suppress AmbiguousMethodReference in AnyLongObjectId
[error prone] fix ReferenceEquality warning in CommitBuilder
[error prone] suppress NonAtomicVolatileUpdate warning in SimpleLruCache
[error prone] fix ReferenceEquality warning in CommitGraphPane#authorFor
[error prone] fix ReferenceEquality warning in RevWalk#isMergedInto
[error prone] fix ReferenceEquality warning in RefUpdate#updateImpl
[error prone] fix ReferenceEquality warning in static equals methods
[error prone] suppress AmbiguousMethodReference in AnyObjectId
[error prone] fix "FutureReturnValueIgnored" error in FS
Fix formatting and add missing braces in Repository#stripWorkDir
Repository: fix reference comparison of Files
MergeAlgorithm: Suppress Error Prone warning about reference equality
Fix NarrowingCompoundAssignment warnings from Error Prone
FS_POSIX: handle Files.getFileStore() failures
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 FileChannel.open 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
GlobalBundleCache: Fix ClassNewInstance warning from Error Prone
IncorrectObjectTypeException: Fix typos in constructors' Javadoc
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
Error Prone: Increase severity of NonOverridingEquals to ERROR
Error Prone: Increase severity of ImmutableEnumChecker to ERROR
GitDateParser#ParseableSimpleDateFormat: Make formatStr private final
BatchRefUpdateTest: Suppress ImmutableEnumChecker warning
PacketLineIn: Suppress comparison warnings for END and DELIM
FileSnapshot#toString: Suppress ReferenceEquality warnings
Blame: Suppress ReferenceEquality warning for RevCommit instances
Fix API problem filters
pgm: add missing optional dependency to org.tukaani:xz
NetscapeCookieFile: Make hash static and group overloaded write
NetscapeCookieFile: Javadoc fixes
Config: Handle reference-equality warning (and empty javadoc)
Error Prone: Increase severity of ShortCircuitBoolean to ERROR
ObjectWalk: Prefer boolean operators over logical operators in comparisons
BasePackFetchConnection: Prefer boolean operators over logical operators in comparisons
PackWriter: Prefer boolean operators over logical operators in comparisons
Change-Id: I825fd55bcb5345fb7afe066bf54ca50325f40acb
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
Diffstat (limited to 'org.eclipse.jgit.http.server/src')
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java | 8 | ||||
-rw-r--r-- | org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java | 9 |
2 files changed, 12 insertions, 5 deletions
diff --git a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java index 05510a05b0..946fb15a3d 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/FileSender.java @@ -58,12 +58,14 @@ import java.io.IOException; import java.io.OutputStream; import java.io.RandomAccessFile; 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/ObjectFileServlet.java b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java index 62f075c73c..5a27be6430 100644 --- a/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java +++ b/org.eclipse.jgit.http.server/src/org/eclipse/jgit/http/server/ObjectFileServlet.java @@ -54,6 +54,7 @@ import static org.eclipse.jgit.util.HttpSupport.HDR_LAST_MODIFIED; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; +import java.time.Instant; import javax.servlet.ServletException; import javax.servlet.http.HttpServlet; @@ -76,7 +77,9 @@ abstract class ObjectFileServlet extends HttpServlet { @Override 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 + // https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.29 + final long lastModified = sender.getLastModified().getEpochSecond(); String ifNoneMatch = req.getHeader(HDR_IF_NONE_MATCH); if (etag != null && etag.equals(ifNoneMatch)) { |