Commit Graph

5445 Commits

Author SHA1 Message Date
David Pursehouse 1780a12e20 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: Id8eb635094336567d9f3c28ec985cd5127d31632
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:16:01 +09:00
David Pursehouse 531da4e5e9 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Fix ObjectUploadListener#close
  Fix error handling in FileLfsServlet
  ObjectDownloadListener#onWritePossible: Make code spec compatible
  ObjectDownloadListener: Return from onWritePossible when data is written
  Fix IOException when LockToken#close fails

Change-Id: Iad9836811be034cf992ea25dad4409addba75115
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-18 09:15:24 +09:00
Matthias Sohn 1a4e12a451 Fix ObjectUploadListener#close
Do not try to set response status if response is already committed.

Change-Id: I9a7c2871c86eb53416b905324775f3ed961c8ae6
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-18 01:29:58 +02:00
Matthias Sohn c18c768678 Fix error handling in FileLfsServlet
Check in #sendError method if the response was committed already.

If yes we cannot set response status or send an error message, last
resort is to close the outputstream.

If the response wasn't yet committed first reset the response before
using writer to send the error message to the client since mixing STREAM
and WRITE mode (mixing asynchronous and blocking I/O) is illegal in
servlet 3.1.

see the following bugs in the gerrit and jetty issue trackers
https://bugs.chromium.org/p/gerrit/issues/detail?id=9667
https://bugs.chromium.org/p/gerrit/issues/detail?id=9721
https://github.com/eclipse/jetty.project/issues/2911

Change-Id: Ie35563c2e0ac1c5e918185a746622589a880dc7f
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-17 17:48:55 +02:00
David Ostrovsky 5c134f4d42 ObjectDownloadListener#onWritePossible: Make code spec compatible
Current code violates the ServletOutputStream contract. For every
out.isReady() == true either write or close of that ServletOutputStream
should be called.

See also this issue upstream for more context: [1].

[1] https://github.com/eclipse/jetty.project/issues/2911

Change-Id: Ied575f3603a6be0d2dafc6c3329d685fc212c7a3
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-17 06:46:16 -05:00
David Ostrovsky f8e514c74a ObjectDownloadListener: Return from onWritePossible when data is written
When buffer was written not only call AsyncContext#complete() but also
return from the ObjectDownloadListener#onWritePossible(). This avoids
endless loop after upgrading from Jetty 9.3.x to 9.4.x lines.

In Jetty example implementation:[1] the return statemnt is also used:

  // If we are at EOF then complete
  if (len < 0)
  {
    async.complete();
    return;
  }

See also this issue upstream: [2].

[1] https://webtide.com/servlet-3-1-async-io-and-jetty
[2] https://github.com/eclipse/jetty.project/issues/2911

Change-Id: Iac73fb25e67d40228a378a8e34103f1d28b72a76
Signed-off-by: David Ostrovsky <david@ostrovsky.org>
2018-09-15 19:20:55 -05:00
Matthias Sohn e6e9073fc7 Fix IOException when LockToken#close fails
This happened if the LockTokens hard link was already deleted earlier.

Bug: 531759
Change-Id: Idc84bd695fac1a763b3cbb797c9c4c636a16e329
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-15 09:11:17 +02:00
David Pursehouse b81092cc99 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory

Change-Id: I5e6cc35f3673545e7ff857e6ed0bcd2c44e50316
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 15:55:07 +09:00
David Pursehouse db756e9147 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Fix NoSuchFileException during directory cleanup in RefDirectory
  Externalize warning message in RefDirectory.delete()
  Suppress warning for trying to delete non-empty directory

Change-Id: I9ec6352b5ff57aa1a3380079dc9165890cc76d49
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 14:05:54 +09:00
Matthias Sohn 667ac8b318 Fix NoSuchFileException during directory cleanup in RefDirectory
Bug: 538285
Change-Id: Iab5c381a412cb2c2176af55189668c267ed29fbc
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 8ab89ef066)
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-12 09:12:11 +09:00
Matthias Sohn c78d6445ec Externalize warning message in RefDirectory.delete()
Change-Id: Icec16c01853a3f5ea016d454b3d48624498efcce
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
(cherry picked from commit 5e68fe245f)
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-11 08:29:02 +09:00
Thomas Wolf 94fad4412a Suppress warning for trying to delete non-empty directory
This is actually a fairly common occurrence; deleting the parent
directories can work only if the file deleted was the last one
in the directory.

Bug: 537872
Change-Id: I86d1d45e1e2631332025ff24af8dfd46c9725711
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
(cherry picked from commit d9e767b431)
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-09-11 08:26:52 +09:00
Matthias Sohn de0a687948 Prepare 4.9.5-SNAPSHOT builds
Change-Id: Ie8d2b60be1803399027e1a3e9734625278a63861
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 09:36:35 +02:00
Matthias Sohn 6657f93adb JGit v4.9.4.201809090327-r
Change-Id: I13488a915fe0ba871c5f37c6e9efc6f436083171
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 09:29:05 +02:00
Matthias Sohn f8de0596d7 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix @since tag for LOCK_SUFFIX
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: Id3c85149316cbe671e55f41438bd3a3a892b4ed0
2018-09-09 09:25:54 +02:00
Matthias Sohn 81735222c9 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Prepare 4.7.4-SNAPSHOT builds
  JGit v4.7.3.201809090215-r

Change-Id: I980807ad4701f9e510354b505c9556e123f32471
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 08:48:59 +02:00
Matthias Sohn b0a0c1004f Fix @since tag for LOCK_SUFFIX
Change-Id: Ia65cf3f12ec6d35a21b4d9332be912f06d8bf834
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 08:46:11 +02:00
Matthias Sohn 6fe4505b2a Prepare 4.7.4-SNAPSHOT builds
Change-Id: Ie4d17e1604270946606e75145012c5b7fa1283eb
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 08:24:16 +02:00
Matthias Sohn 9796e86165 JGit v4.7.3.201809090215-r
Change-Id: I1ded7a2b61235509c5a6ba95e7329e288bbfddb1
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-09 08:15:48 +02:00
Matthias Sohn 4ce79bf738 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix atomic lock file creation on NFS
  Use constant for ".lock"
  Fix handling of option core.supportsAtomicCreateNewFile
  GC: Avoid logging errors when deleting non-empty folders

Change-Id: Id7f68f4e8fb07a21737e3b7090f600507a13bbbe
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-08 09:15:01 +02:00
Matthias Sohn 8699a95d2d Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Fix atomic lock file creation on NFS
  Use constant for ".lock"
  Fix handling of option core.supportsAtomicCreateNewFile
  GC: Avoid logging errors when deleting non-empty folders

Change-Id: Ia7a18f69eee173aec9e462c16eee2b0ca4565e76
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-08 08:58:12 +02:00
Matthias Sohn 06e06fc291 Fix atomic lock file creation on NFS
FS_POSIX.createNewFile(File) failed to properly implement atomic file
creation on NFS using the algorithm [1]:
- name of the hard link must be unique to prevent that two processes
  using different NFS clients try to create the same link. This would
  render nlink useless to detect if there was a race.
- the hard link must be retained for the lifetime of the file since we
  don't know when the state of the involved NFS clients will be
  synchronized. This depends on NFS configuration options.

To fix these issues we need to change the signature of createNewFile
which would break API. Hence deprecate the old method
FS.createNewFile(File) and add a new method createNewFileAtomic(File).

The new method returns a LockToken which needs to be retained by the
caller (LockFile) until all involved NFS clients synchronized their
state. Since we don't know when the NFS caches are synchronized we need
to retain the token until the corresponding file is no longer needed.
The LockToken must be closed after the LockFile using it has been
committed or unlocked. On Posix, if core.supportsAtomicCreateNewFile =
false this will delete the hard link which guarded the atomic creation
of the file. When acquiring the lock fails ensure that the hard link is
removed.

[1] https://www.time-travellers.org/shane/papers/NFS_considered_harmful.html
also see file creation flag O_EXCL in
http://man7.org/linux/man-pages/man2/open.2.html

Change-Id: I84fcb16143a5f877e9b08c6ee0ff8fa4ea68a90d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-07 12:13:53 +02:00
Matthias Sohn 6bec391d36 Use constant for ".lock"
(cherry picked from commit 5f27032fb8)

Change-Id: I6bc0e9a910b110418a82d8e574fb2aecc3a31d6a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-09-07 12:13:53 +02:00
Christian Halstrick 2faccd5b32 Fix handling of option core.supportsAtomicCreateNewFile
When core.supportsAtomicCreateNewFile was set to false and the
repository was located on a filesystem which doesn't support the file
attribute "unix:nlink" then FS_POSIX#createNewFile may report an error
even if everything was ok. Modify FS_POSIX#createNewFile to silently
ignore this situation. An example of such a filesystem is sshfs where
reading "unix:nlink" always returns 1 (instead of throwing a exception).

Bug: 537969
Change-Id: I6deda7672fa7945efa8706ea1cd652272604ff19
Also-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-09-07 00:33:14 +02:00
Hector Caballero b7351facd5 GC: Avoid logging errors when deleting non-empty folders
I88304d34c and Ia555bce00 modified the way errors are handled when
trying to delete non-empty reference folders. Before, this error was
silently ignored as it was considered an expected output. Now, every
failed folder delete is logged which can be noisy.

Ignore the DirectoryNotEmptyException but log any other error avoiding
deletion of an eligible folder.

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: I194512f67885231d62c03976ae683e5cc450ec7c
2018-09-05 06:59:51 -04:00
David Pursehouse a074203fa9 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I17436237cd66ca1c2800ad5ab0142f4a2bc07328
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 13:14:28 +09:00
David Pursehouse b270e4b740 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Bazel: Use hyphen instead of underscore in external repository names
  Bazel: Format all build files with buildifier 0.15.0
  ChangeIdUtilTest: Remove unused notestCommitDashV

Change-Id: I414ade902dc38b696c566dd604000e3d289f3973
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-31 09:25:43 +09:00
David Pursehouse af547cf00d Bazel: Use hyphen instead of underscore in external repository names
Recent Bazel versions support the hyphen character in external
repository names. On the Gerrit project, the repository names
were harmonized to consistently use hyphen.

As a side effect, it is no longer possible to build jgit from source
in the gerrit tree, due to the different repository names.

Rename the dependencies to use hyphens, consistent with gerrit.

Change-Id: Ideebd858ddd3f0e6f765643001642dfb6c12441f
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-30 15:28:06 +09:00
David Pursehouse 487571e604 Bazel: Format all build files with buildifier 0.15.0
Change-Id: I8343b723da6e40d5ae7fc45c84f64c31276bd5dc
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-30 15:27:20 +09:00
David Pursehouse ee56e5fc04 ChangeIdUtilTest: Remove unused notestCommitDashV
This test was never being run. Since it was introduced it was
named "notest.." which meant it didn't run with JUnit3, and
since it is not annotated @Test it also doesn't run with JUnit4.

When compiling with Bazel 0.6.0, error-prone raises an error
that the public method is not annotated with @Ignore or @Test.

Given that the test has never been run anyway, we can just
remove it.

Bug: 525415
Change-Id: Ie9a54f89fe42e0c201f547ff54ff1d419ce37864
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-08-30 15:25:38 +09:00
Matthias Sohn b0332d0133 Ignore API warnings
The following commits introduced in stable-4.5 and stable-4.9
introduced some minor API additions in service releases.

f7ceeaa2 FileRepository: Add pack-based inserter implementation
085d1f95 Make PackInserter public
10e65cb4 Fix LockFile semantics when running on NFS

Change-Id: I4afed7e0395cf93d828e671080e3ec9ddf20987d
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-24 17:23:00 +02:00
Matthias Sohn 7446d576e2 Fix photon target platform to use photon version of org.eclipse.osgi
Change-Id: I81cb499a5092eed6569f6fdf612ecab3f5d9bd5e
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-24 16:30:04 +02:00
Matthias Sohn c0c2dea8b0 Update Photon orbit repository to R20180606145124
The S-repository doesn't exist anymore and we should have updated to the
final Photon orbit repository already.

Change-Id: I6d1757833be4abd3643677d6e7814363533e88b2
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-23 11:29:15 +02:00
Thomas Wolf d9e767b431 Suppress warning for trying to delete non-empty directory
This is actually a fairly common occurrence; deleting the parent
directories can work only if the file deleted was the last one
in the directory.

Bug: 537872
Change-Id: I86d1d45e1e2631332025ff24af8dfd46c9725711
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-08-22 18:36:31 +02:00
Thomas Wolf ffd1ac5dde Fix fetching with duplicate ref updates
If packed refs are used, duplicate updates result in an exception
because JGit tries to lock the same lock file twice. With non-atomic
ref updates, this used to work, since the same ref would simply be
locked and updated twice in succession.

Let's be more lenient in this case and remove duplicates before
trying to do the ref updates. Silently skip duplicate updates
for the same ref, if they both would update the ref to the same
object ID. (If they don't, behavior is undefined anyway, and we
still throw an exception.)

Add a test that results in a duplicate ref update for a tag.

Bug: 529400
Change-Id: Ide97f20b219646ac24c22e28de0c194a29cb62a5
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-08-22 11:09:01 +02:00
Marc Strapetz 65a0cfc82a Fetch(Process): should tolerate duplicate refspecs
Bug: 529314
Change-Id: I91eaeda8a988d4786908fba6de00478cfc47a2a2
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-08-22 11:09:00 +02:00
Marc Strapetz 109c07ac8e FetchCommandTest: test add/update/delete fetch
Change-Id: I2442394fb7eae5b3715779555477dd27b274ee83
Signed-off-by: Marc Strapetz <marc.strapetz@syntevo.com>
Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
2018-08-22 11:08:58 +02:00
Matthias Sohn ce84d0dfc6 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Fix GC run in foreground to not use executor

Change-Id: Id9d864a8e727fefa35ca87eccb4e3801eb689c3c
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-18 13:47:51 +02:00
Matthias Sohn 96beadbbc1 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Fix GC run in foreground to not use executor

Change-Id: Ib150d132e2ce055d36ddffb2dbc37b5cb355e77a
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-08-18 13:40:33 +02:00
Hugo Arès d4a19c328f Fix GC run in foreground to not use executor
Since I3870cadb4, GC task was always delegated to an executor even when
background option was set to false. This was an issue because if more
than one GC object was instantiated and executed in parallel, only one GC
was actually running because of the single thread executor.

Change-Id: I8c587d22d63c1601b7d75914692644a385cd86d6
Signed-off-by: Hugo Arès <hugo.ares@ericsson.com>
2018-08-15 19:53:33 -05:00
Matthias Sohn 6a813c64ff Prepare 4.9.4-SNAPSHOT builds
Change-Id: Ibb2ee9d00d5d049f681e1abbb449656105e553a7
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-07-31 16:57:13 +02:00
Matthias Sohn 56b435a61c JGit v4.9.3.201807311005-r
Change-Id: I3f4f437649736c6a27e78d536344c7b31c8a0f65
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-07-31 16:05:49 +02:00
Matthias Sohn a0b818ce01 Merge branch 'stable-4.8' into stable-4.9
* stable-4.8:
  Prepare 4.7.3-SNAPSHOT builds
  JGit v4.7.2.201807261330-r
  Delete all loose refs empty directories
  Use java.nio to delete path to get detailed errors
  GC: Remove empty references folders
  Do not ignore path deletion errors

Change-Id: I6ab2b951dd94a9fc1c4f5283847a3e2ec37d0895
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-07-27 10:52:13 +02:00
David Pursehouse e90a013e45 Merge branch 'stable-4.7' into stable-4.8
* stable-4.7:
  Prepare 4.7.3-SNAPSHOT builds
  JGit v4.7.2.201807261330-r
  Delete all loose refs empty directories
  Use java.nio to delete path to get detailed errors
  GC: Remove empty references folders
  Do not ignore path deletion errors

Change-Id: Iadc8275fbaa3d6f7d08a96ab66d49f392f6aab78
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-07-27 08:22:51 +01:00
Matthias Sohn 29118ed117 Prepare 4.7.3-SNAPSHOT builds
Change-Id: I5c437f45d5bc469e3c32bef1180c127d96d24d23
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-07-27 01:00:35 +02:00
Matthias Sohn 01787756aa JGit v4.7.2.201807261330-r
Change-Id: I0d8c7ca756e6236e315c91da000fe8103ce83d05
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-07-26 19:28:38 +02:00
Luca Milanesio 977726e5bb Delete all loose refs empty directories
Remove completely the empty directories under refs/<namespace>
including the first level partition of the changes, when they are
completely empty.

Bug: 536777
Change-Id: I88304d34cc42435919c2d1480258684d993dfdca
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-07-26 01:13:56 +02:00
Luca Milanesio eea9a7a0ba Use java.nio to delete path to get detailed errors
Get the full IOException of the reason why a directory
cannot be removed during GC.

Change-Id: Ia555bce009fa48087a73d677f1ce3b9c0b685b57
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
2018-07-26 01:02:42 +02:00
Hector Caballero 4eea4ea508 GC: Remove empty references folders
After packaging references, the folders containing these references are
not deleted. In a busy repository, this causes operations to slow down
as traversing the references tree becomes longer.

Delete empty reference folders after the loose references have been
packed.
To avoid deleting a folder that was just created by another concurrent
operation, only delete folders that were not modified in the last 30
seconds.

Signed-off-by: Hector Oswaldo Caballero <hector.caballero@ericsson.com>
Change-Id: Ie79447d6121271cf5e25171be377ea396c7028e0
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
2018-07-10 20:24:59 +09:00
Luca Milanesio 5a8ad44208 Do not ignore path deletion errors
Log as warning when an attempt to remove a directory
fails. This helps troubleshooting some bugs like the GC leaving
behind empty directories.

Change-Id: Idb94ce17f8be9668a970c7ecae31436bf434073c
Signed-off-by: Luca Milanesio <luca.milanesio@gmail.com>
2018-07-08 23:44:17 +01:00