Skip to main content
summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)AuthorFilesLines
2019-10-09http: Allow specifying a custom error handler for UploadPackMasaya Suzuki3-27/+118
By abstracting the error handler, this lets a user customize the error handler for UploadPack. A customized error handler can show a custom error message to the clients based on the exception thrown from the hook, create a monitoring system for server errors, or do custom logging. Change-Id: Idd3b87d6bd471fef807c0cf1183e904b2886157e Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2019-08-09Merge branch 'stable-5.4'Matthias Sohn2-5/+12
* 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>
2019-08-08Merge branch 'stable-5.3' into stable-5.4Matthias Sohn2-5/+12
* stable-5.3: 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 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: Iec3ad6ccc194582cb844310dc172c3103dae4457 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-08-08Merge branch 'stable-5.2' into stable-5.3Matthias Sohn2-5/+12
* 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 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 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 <matthias.sohn@sap.com>
2019-08-08Merge branch 'stable-5.1' into stable-5.2Matthias Sohn2-5/+12
* stable-5.1: 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 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: Ia57385b2a60f48a5317c8d723721c235d7043a84 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-08-02Constants for objects and info/{http-,}alternatesDavid Turner1-2/+2
These are useful to avoid typos, and also for tab completion. Change-Id: I0f2d267e46b36bc40297c9657c447f3fd8b9f831 Signed-off-by: David Turner <dturner@twosigma.com>
2019-07-18Use Instant instead of milliseconds for filesystem timestamp handlingMatthias Sohn2-5/+12
This enables higher file timestamp resolution on filesystems like ext4, Mac APFS (1ns) or NTFS (100ns) providing high timestamp resolution on filesystem level. Note: - on some OSes Java 8,9 truncate milliseconds, see https://bugs.openjdk.java.net/browse/JDK-8177809, fixed in Java 10 - UnixFileAttributes truncates timestamp resolution to microseconds when converting the internal representation to FileTime exposed in the API, see https://bugs.openjdk.java.net/browse/JDK-8181493 - WindowsFileAttributes also provides only microsecond resolution Change-Id: I25ffff31a3c6f725fc345d4ddc2f26da3b88f6f2 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-06-19Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8David Pursehouse2-3/+4
Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-06-05Repository: Add getIdentifier() method to avoid instanceof operatorDavid Ostrovsky1-6/+4
This change is needed to implement permission aware ref database in Gerrit: [1], that is a pre-requisite to re-enable Git v2 protocol in Gerrit: [2]. Background: Last year Git v2 protocol was enabled in Gerrit. The fact, that JGit layer was not calling ref advertise filter for Git v2 protocol, introduced security vulnerability. The lesson learned from this security incident: Gerrit should not rely on ref advertise filter being called by JGit to implement crictical security checks. Instead, the idea is to use the same approach as currently used by Google's internal code on googlesource.com that didn't suffer from this vulnerability: provide a custom repository to JGit. The repository provides a RefDatabase that is permission-aware and will only ever return refs that the user has access to. However, due to hard coded instanceof operator usages in JGit code base, some tests in Gerrit are failing with: [1] in place. This change addresses this problem. [1] https://gerrit-review.googlesource.com/c/gerrit/+/212874 [2] https://gerrit-review.googlesource.com/c/gerrit/+/226754 Change-Id: I67c0f53ca33b149442e7ee3e51910d19e3f348d5 Signed-off-by: David Ostrovsky <david@ostrovsky.org> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-05-16Convert to lambda or member referenceCarsten Hammer1-9/+4
Convert anonymous inner classes to lambda expressions or member references Bug: 545856 CQ: 19537 Change-Id: I621431c178e8b99316314602f7c66c9a36f9ae98 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2019-04-11Remove unnecessary type specificationsCarsten Hammer1-1/+1
Since Java 7 the diamond operator can be used instead of explicit type parameters. Change-Id: I2dee5fce7afebb1d9088eeaec4484ee58b4fa492 Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de> Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2019-01-21GitSmartHttpTools: Open SideBandOutputStream in try-with-resourceDavid Pursehouse1-4/+5
Change-Id: Ie7c17f98579e7241f2b5c8204435c76686eeb568 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-12-31Replace deprecated FirstLine by FirstCommandMichael Keppler1-1/+2
and allow package org.eclipse.jgit.http.server to use package org.eclipse.jgit.internal.transport.parser. Change-Id: Ief330c3e75a735853d0a5a265a9ff56fb5128b99 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-11-21Remove unnecessary modifiers from interfacesJonathan Nieder1-2/+2
This continues what commit d9ac7ddf1026123fee6c4477d172d614522dfc08 (Remove unnecessary modifiers from interfaces, 2018-11-15) started. Change-Id: I89720985a5a986722a0dcb9b5e9bbc25996bd5b3
2018-11-19Revert C Git 1.7.5 bug workaroundMasaya Suzuki3-38/+6
This reverts the workaround introduced by 1c6c73c5a9b8dd700be45d658f165a464265dba7, which is a patch for dealing with a buggy C Git client v1.7.5 in 2012. We'll stop supporting very old C Git clients. Change-Id: I94999a39101c96f210b5eca3c2f620c15eb1ac1b Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2018-10-12Move first line parsing for v0/v1 pack negotiation out of UploadPackIvan Frade1-3/+4
In protocol v0/v1 pack negotiation, the first want line contains the options the client wants in effect. This parsing is done in UploadPack but it doesn't have any interaction with that class. Move the code to its own class and package, mark the current one as deprecated (it is public API) and add unit tests. Take the chance to move the parsing code from the constructor to a factory method, making the class a simple container of results. Change-Id: I1757f535dda78a4111a1c12c3a3b455a4b6f0c51 Signed-off-by: Ivan Frade <ifrade@google.com>
2018-09-30Deprecate Constants.CHARACTER_ENCODING in favor of StandardCharsets.UTF_8David Pursehouse2-3/+4
Change-Id: I621ba174235a6fb56236e54d24bce704bb5afb28 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-15SmartOutputStream: Suppress false-positive resource leak warningDavid Pursehouse1-0/+1
Change-Id: I013841ed2584f061c680a8adf0f777dcae3c5418 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-04Deprecate Constants.CHARSET in favor of StandardCharsets.UTF_8David Pursehouse1-1/+2
Change-Id: I3b748620f067582afef20f144feebe40d0332be2 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-23refactor: simplify collection.toArray()Michael Keppler2-2/+2
On recent VMs, collection.toArray(new T[0]) is faster than collection.toArray(new T[collection.size()]). Since it is also more readable, it should now be the preferred way of collection to array conversion. https://shipilev.net/blog/2016/arrays-wisdom-ancients/ Change-Id: I80388532fb4b2b0663ee1fe8baa94f5df55c8442 Signed-off-by: Michael Keppler <Michael.Keppler@gmx.de>
2018-06-05Add protocol v2 support in httpJonathan Tan2-3/+32
Teach UploadPack to support protocol v2 with non-bidirectional pipes, and add support to the HTTP protocol for v2. This is only activated if the repository's config has "protocol.version" equal to 2. Change-Id: I093a14acd2c3850b8b98e14936a716958f35a848 Helped-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-06-05Give info/refs services more control over responseJonathan Tan1-3/+32
Currently, SmartServiceInfoRefs always prints "# service=serviceName" followed by a flush packet in response to an info/refs request, and then hands it off to the specific service class. Printing of "# service=serviceName" is mandated for protocol v0, but not v2. Therefore, the existing code works for protocol v0, but whenever a service that supports protocol v2 receives an info/refs request, it must first determine which protocol version is to be used (depending on, for example, the request and any relevant configuration variables), and then decide if "# service=serviceName" needs to be printed. Create a new method that v2-supporting service classes can override, covering the printing of both "# service=serviceName" and everything that the #advertise method prints. This will be used in a subsequent commit in which UploadPackServlet (and the other classes it uses) is updated to support protocol v2. Change-Id: Ia026b06e96a6b15937514096babd024ef77df1ea Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Jonathan Nieder <jrn@google.com>
2018-05-21InfoRefsServlet: Refactor to not use deprecated methodsDavid Pursehouse1-7/+1
- Replace RefDatabase#getRefs(String) with #getRefsByPrefix(String) - Replace RefAdvertiser#send(Map<String, Ref>) with #send(Collection<Ref>) Bug: 534731 Change-Id: I25b617c3b0c54793cf4ab5b62f002e17745a5377 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-05-18Remove further unnecessary 'final' keywordsHan-Wen Nienhuys12-20/+20
Remove it from * package private functions. * try blocks * for loops this was done with the following python script: $ cat f.py import sys import re import os def replaceFinal(m): return m.group(1) + "(" + m.group(2).replace('final ', '') + ")" methodDecl = re.compile(r"^([\t ]*[a-zA-Z_ ]+)\(([^)]*)\)") def subst(fn): input = open(fn) os.rename(fn, fn + "~") dest = open(fn, 'w') for l in input: l = methodDecl.sub(replaceFinal, l) dest.write(l) dest.close() for root, dirs, files in os.walk(".", topdown=False): for f in files: if not f.endswith('.java'): continue full = os.path.join(root, f) print full subst(full) Change-Id: If533a75a417594fc893e7c669d2c1f0f6caeb7ca Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
2018-05-15Remove 'final' in parameter listsHan-Wen Nienhuys13-18/+18
Change-Id: Id924f79c8b2c720297ebc49bf9c5d4ddd6d52547 Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
2018-03-14RepositoryFilter: Refactor doFilter to open Repository in try-with-resourceDavid Pursehouse1-8/+3
Change-Id: Ic4a056eebe567ff933519d6a805edb7e97c71b22 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-13Open auto-closeable resources in try-with-resourceDavid Pursehouse2-12/+3
When an auto-closeable resources is not opened in try-with-resource, the warning "should be managed by try-with-resource" is emitted by Eclipse. Fix the ones that can be silenced simply by moving the declaration of the variable into a try-with-resource. In cases where we explicitly call the close() method, for example in tests where we are testing specific behavior caused by the close(), suppress the warning. Leave the ones that will require more significant refcactoring to fix. They can be done in separate commits that can be reviewed and tested in isolation. Change-Id: I9682cd20fb15167d3c7f9027cecdc82bc50b83c4 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06InfoRefsServlet: Open OutputStreamWriter in try-with-resourceDavid Pursehouse1-21/+22
Change-Id: Iaf93d5c020ee67e9effbe93334f1ad419ffaee1f Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06GitSmartHttpTools: Open OutputStream in try-with-resourceDavid Pursehouse1-4/+1
Change-Id: Ifb50b923f58f73d323cc1492950e58b6dc39f376 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-03-06FileSender: Open OutputStream in try-with-resourceDavid Pursehouse1-4/+1
Change-Id: I2278950998dffc2b5730a91a5bb3bcc38f4d446b Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-12-17Fix javadoc in org.eclipse.jgit.http.serverMatthias Sohn31-64/+204
Change-Id: I732d773b21bbf64285493070964dd9e442eab5d8 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-08-30Cleanup: Remove unnecessary $NON-NLS$ tagsMatthias Sohn1-1/+1
Change-Id: I143c9d62b89322509123d4e06a221dd4dc158c55 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2017-08-25Show error message for non-git clientsMasaya Suzuki1-1/+1
Change-Id: I56435d955348eb9acef6603d868f9add1c8781c9 Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2017-08-02Eliminate SectionParser construction boilerplateDave Borowitz3-27/+3
Happily, most anonymous SectionParser implementations can be replaced with FooConfig::new, as long as the constructor takes a single Config arg. Many of these, the non-public ones, can in turn be inlined. A few remaining SectionParsers can be lambdas. Change-Id: I3f563e752dfd2007dd3a48d6d313d20e2685943a
2017-07-25Add missing newlines at ends of Java filesDavid Pursehouse1-1/+1
Change-Id: Iead36f53d57ead0eb3edd3f9efb63b6630c9c20c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-02-20Enable and fix warnings about redundant specification of type argumentsDavid Pursehouse3-5/+5
Since the introduction of generic type parameter inference in Java 7, it's not necessary to explicitly specify the type of generic parameters. Enable the warning in Eclipse, and fix all occurrences. Change-Id: I9158caf1beca5e4980b6240ac401f3868520aad0 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2017-02-20Enable and fix 'Should be tagged with @Override' warningDavid Pursehouse23-0/+62
Set missingOverrideAnnotation=warning in Eclipse compiler preferences which enables the warning: The method <method> of type <type> should be tagged with @Override since it actually overrides a superclass method Justification for this warning is described in: http://stackoverflow.com/a/94411/381622 Enabling this causes in excess of 1000 warnings across the entire code-base. They are very easy to fix automatically with Eclipse's "Quick Fix" tool. Fix all of them except 2 which cause compilation failure when the project is built with mvn; add TODO comments on those for further investigation. Change-Id: I5772061041fd361fe93137fd8b0ad356e748a29c Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-11-23dump HTTP: Avoid being confused by Content-Length of a gzipped streamZhen Chen1-1/+2
TransportHttp sets 'Accept-Encoding: gzip' to allow the server to compress HTTP responses. When fetching a loose object over HTTP, it uses the following code to read the response: InputStream in = openInputStream(c); int len = c.getContentLength(); return new FileStream(in, len); If the content is gzipped, openInputStream decompresses it and produces the correct content for the object. Unfortunately the Content-Length header contains the length of the compressed stream instead of the actual content length. Use a length of -1 instead since we don't know the actual length. Loose objects are already compressed, so the gzip encoding typically produces a longer compressed payload. The value from the Content-Length is too high, producing EOFException: Short read of block. Change-Id: I8d5284dad608e3abd8217823da2b365e8cd998b0 Signed-off-by: Zhen Chen <czhen@google.com> Helped-by: Jonathan Nieder <jrn@google.com>
2016-11-14Organize importsDavid Pursehouse5-9/+9
Change-Id: I7c545d06b1bced678c020fab9af1382bc4416b6e Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-09-22WrappedRequest: Don't use deprecated ServletRequestWrapper#realPathDavid Pursehouse1-1/+1
Change-Id: I268e66d2299a1a12f7ae44b67a6b947339038245 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2016-08-24Add HTTP status code to ServiceMayNotContinueExceptionMasaya Suzuki3-3/+3
The exception can be thrown in a various reason, and sometimes 403 Forbidden is not appropriate. Make the HTTP status code customizable. Change-Id: If2ef6f454f7479158a4e28a12909837db483521c Signed-off-by: Masaya Suzuki <masayasuzuki@google.com>
2015-07-09Report PackProtocolExceptions to client during receive-packDave Borowitz1-1/+2
We have done this since forever with the "wanted old new ref" error, so let's do it for other such errors thrown in the same block as well. Change-Id: Ib3b1c7f05e31a5b3e40e85eb07b16736920a033b
2015-06-02Use message from ServiceNotAuthorizedException, ServiceNotEnabledExceptionJonathan Nieder5-15/+11
When sending an error response due to ServiceNotAuthorizedException or ServiceNotEnabledException, usually we send a default message. In the ServiceNotEnabledException case, we use 403 Git access forbidden except in a dumb-HTTP-specific filter where we use the servlet container's default 403 response: 403 Forbidden In the ServiceNotAuthorizedException case, we use the servlet container's default 401 response: 401 Unauthorized There is one exception: a ServiceNotEnabledException when handling a smart HTTP /info/refs request uses the message from the exception: 403 Service not enabled Be more consistent by always using the message from the exception. This way, authors of a RepositoryResolver, UploadPackFactory, or ReceivePackFactory can provide a more detailed message when appropriate. The defaults are 401 Unauthorized 403 Service not enabled Change-Id: Id1fe1c2042fb96487c3671c1965c8a65c4b8e1b8 Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-06-02dumb HTTP: Clarify AsIsFilter by introducing req and res localsJonathan Nieder1-3/+5
No functional change. Change-Id: I945ba18879c360f433e026aa125ef3f9f6a75793 Signed-off-by: Jonathan Nieder <jrn@google.com>
2015-05-21Replace deprecated release() methods by close()Matthias Sohn2-2/+2
See the discussion [1] in the Gerrit mailing list. [1] https://groups.google.com/forum/#!topic/repo-discuss/RRQT_xCqz4o Change-Id: I2c67384309c5c2e8511a7d0d4e088b4e95f819ff Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2015-05-06Skip logging stack trace on corrupt objectsShawn Pearce2-0/+11
Instead of dumping a full stack trace when a client sends an invalid commit, record only a short line explaining the attempt: Cannot receive Invalid commit c0ff33...: invalid author into /tmp/jgit.git The text alone is sufficient to explain the problem and the stack trace does not lend any additional useful information. ObjectChecker is quite clear about its rejection cases. Change-Id: Ifc8cf06032489dc6431be1ba66101cf3d4299218
2015-05-06Add repository name to failures in HTTP server logShawn Pearce3-9/+29
If UploadPack or ReceivePack has an exception record an identifier associated with the repository as part of the log message. This can help the HTTP admin track down the offending repository and take action to repair the root cause. Change-Id: I58f22b33cdb40994f044a26fba9fe965b45be51d
2015-04-30Support agent= capability in wire protocolShawn Pearce2-0/+8
Since git-core ff5effd (v1.7.12.1) the native wire protocol transmits the server and client implementation and version strings using capability "agent=git/1.7.12.1" or similar. Support this in JGit and hang the implementation data off UploadPack and ReceivePack. On HTTP transports default to the User-Agent HTTP header until the client overrides this with the optional capability string in the first line. Extract the user agent string into a UserAgent class under transport where it can be specified to a different value if the application's build process has broken the Implementation-Version header in the JGit package. Change-Id: Icfc6524d84a787386d1786310b421b2f92ae9e65
2015-04-03Clearer error message when service is not enabledHector Oswaldo Caballero1-1/+1
When a user tried to use a service not enabled in the remote server a misleading error message was given: fatal: remote error: Git access forbidden This patch modifies the error message to make the cause clearer to the user. Now, when the user tries to use a not enabled service, the message error clearly states it: fatal: remote error: Service not enabled Change-Id: If096c4ddd17c5aae0e99e3ea6eea4b69bd3c5466 Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
2014-12-12Revert "Extract path info from requests without decoding"Shawn Pearce3-50/+4
This reverts commit 19f869996f27adf59ec507e5f565d8b5619576f3. Leaving path info encoded confuses applications like Gitiles. Trying to fix this inside of JGit was maybe the wrong solution. Change-Id: I8df9ab6233ff513e427701c8a1a66022c19784eb

Back to the top