From 89bfdb1e079dcba7ed208da8ab6ab22de3e6aa07 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 4 Sep 2019 15:08:34 +0200 Subject: [PATCH 1/9] Upgrade JGit to 4.11.9.201909030838-r This release fixes - PackedBatchRefUpdate: reproduce racy atomic update, and fix it Release notes: https://projects.eclipse.org/projects/technology.jgit/releases/4.11.9 Bug: Issue 11373 Change-Id: Ia31e0f9b859bc0bc0cf6e532f9ca08b59221c977 --- lib/jgit/jgit.bzl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/jgit/jgit.bzl b/lib/jgit/jgit.bzl index 56f1337f03..141b293b66 100644 --- a/lib/jgit/jgit.bzl +++ b/lib/jgit/jgit.bzl @@ -1,6 +1,6 @@ load("//tools/bzl:maven_jar.bzl", "MAVEN_CENTRAL", "maven_jar") -_JGIT_VERS = "4.11.8.201904181247-r" +_JGIT_VERS = "4.11.9.201909030838-r" _DOC_VERS = _JGIT_VERS # Set to _JGIT_VERS unless using a snapshot @@ -35,28 +35,28 @@ def jgit_maven_repos(): name = "jgit-lib", artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "d7bc31008c827e63d33b14c68eb149dd2087e41b", - src_sha1 = "111ac9eb58c42673f560fa242ea31aec3d0eb7d3", + sha1 = "3bc74ffed6186bf2fc37404216e5ef16f904d0b0", + src_sha1 = "ddfdec70e78d145e7d99c8d72286cb714b0239ae", unsign = True, ) maven_jar( name = "jgit-servlet", artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "ceefadfc63548bce8d3eedf8656759cc1c41b1ee", + sha1 = "a870e53f414992a548264758bdb17c74f6b79e19", unsign = True, ) maven_jar( name = "jgit-archive", artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "10565873a029aad92b18908786a0e097df975175", + sha1 = "65bcf563c3155f9555735992f6493f3fe35b13a2", ) maven_jar( name = "jgit-junit", artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "b8c33396d6083f357cc5ac820814a55aac17f862", + sha1 = "c7a8883d5431149d1d3b9282eda3d79efffd319e", unsign = True, ) From 064f0597e3ae444b42da65b3c5c77b42852c990e Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 4 Sep 2019 18:36:19 +0200 Subject: [PATCH 2/9] Revert "Revert "Stop using deprecated DirCacheEntry#setLastModified(long)"" This reverts commit dd382e8ac9eb7287060a6dfde5227982cff8b888. Change-Id: Ia2dda0461a99cc3f023e34902ca1c5424904d215 --- .../gerrit/server/edit/tree/ChangeFileContentModification.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/java/com/google/gerrit/server/edit/tree/ChangeFileContentModification.java b/java/com/google/gerrit/server/edit/tree/ChangeFileContentModification.java index d91e2e8420..0adacd8461 100644 --- a/java/com/google/gerrit/server/edit/tree/ChangeFileContentModification.java +++ b/java/com/google/gerrit/server/edit/tree/ChangeFileContentModification.java @@ -23,6 +23,7 @@ import com.google.common.io.ByteStreams; import com.google.gerrit.extensions.restapi.RawInput; import java.io.IOException; import java.io.InputStream; +import java.time.Instant; import java.util.Collections; import java.util.List; import org.eclipse.jgit.dircache.DirCacheEditor; @@ -79,7 +80,7 @@ public class ChangeFileContentModification implements TreeModification { try { if (dirCacheEntry.getFileMode() == FileMode.GITLINK) { dirCacheEntry.setLength(0); - dirCacheEntry.setLastModified(0); + dirCacheEntry.setLastModified(Instant.EPOCH); ObjectId newObjectId = ObjectId.fromString(getNewContentBytes(), 0); dirCacheEntry.setObjectId(newObjectId); } else { From 98f442a8282480eff96a4c374248d9193a028dad Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 4 Sep 2019 18:37:56 +0200 Subject: [PATCH 3/9] Revert "Revert "GerritServer: Silence non-critical logs from JGit's FileSnapshot"" This reverts commit 6dba3ba183bce26be0bdf8095b3e9ce3e058612d. Change-Id: I61733b44ba710a986a746b0502ff8c1b5a4eb2f0 --- java/com/google/gerrit/acceptance/GerritServer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/com/google/gerrit/acceptance/GerritServer.java b/java/com/google/gerrit/acceptance/GerritServer.java index 050de49003..a71a87c04c 100644 --- a/java/com/google/gerrit/acceptance/GerritServer.java +++ b/java/com/google/gerrit/acceptance/GerritServer.java @@ -245,6 +245,7 @@ public class GerritServer implements AutoCloseable { // Silence non-critical messages from JGit. .put("org.eclipse.jgit.transport.PacketLineIn", Level.WARN) .put("org.eclipse.jgit.transport.PacketLineOut", Level.WARN) + .put("org.eclipse.jgit.internal.storage.file.FileSnapshot", Level.WARN) .build(); private static boolean forceLocalDisk() { From c89e125c730f2b33c33d45e5cc4b99e5849d95fe Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 4 Sep 2019 18:31:59 +0200 Subject: [PATCH 4/9] Upgrade JGit to 5.1.11.201909031202-r Improvements in 5.1.8 - 5.1.11: - include filekey file attribute (inode on *nix filesystems) when comparing FileSnapshots - optionally wait opening new packfile until it can't be racy anymore - fix FileSnapshot's consideration of file size - ObjectDirectory: fix closing of obsolete packs - measure FileStoreAttributes per filesystem - improve measuring file timestamp resolution - measure minimal racy interval - use Instant to increase resolution to 1us (limited by FileTime) - persist FileStoreAttributes - optional asynchronous measurement of FileStoreAttributes - directory - FileStore cache - cache user and system level gitconfig - fix supportsAtomicCreateNewFile default to true - fix non-deterministic hash of archives created by ArchiveCommand - reproduce racy atomic update in PackedBatchRefUpdate and fix it Release notes: https://projects.eclipse.org/projects/technology.jgit/releases/5.1.8 https://projects.eclipse.org/projects/technology.jgit/releases/5.1.9 https://projects.eclipse.org/projects/technology.jgit/releases/5.1.10 https://projects.eclipse.org/projects/technology.jgit/releases/5.1.11 Change-Id: Ia93eaee442096eabdb999c9c9a6fc0edeb10c0fe --- lib/jgit/jgit.bzl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/jgit/jgit.bzl b/lib/jgit/jgit.bzl index 8fe8b145a6..6aaf925a76 100644 --- a/lib/jgit/jgit.bzl +++ b/lib/jgit/jgit.bzl @@ -1,6 +1,6 @@ load("//tools/bzl:maven_jar.bzl", "MAVEN_CENTRAL", "maven_jar") -_JGIT_VERS = "5.1.7.201904200442-r" +_JGIT_VERS = "5.1.11.201909031202-r" _DOC_VERS = _JGIT_VERS # Set to _JGIT_VERS unless using a snapshot @@ -40,28 +40,28 @@ def jgit_maven_repos(): name = "jgit-lib", artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "ef1f744a1117e3d8916f3770486502a56d241b16", - src_sha1 = "7bf5b5298f8936e959a92f62b5151d58feb9c00a", + sha1 = "5aa0e29d7b4db4e6c17e3ddee9bdc8d578f02ef0", + src_sha1 = "48ae1f24793a18c94d7b2e335ccdee6f16f8dd09", unsign = True, ) maven_jar( name = "jgit-servlet", artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "8306e221fb50985247138adb8ffb0f4cd74c5e9a", + sha1 = "2650749548a85adf53ffa7c334834edf3411d7c7", unsign = True, ) maven_jar( name = "jgit-archive", artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "fefb13ab8331cc8b13a15b653b1e057de7d3e514", + sha1 = "0eb22173603c141047c790e28f9d8a1df39b8067", ) maven_jar( name = "jgit-junit", artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "f73f1eacc38f8329d9453f1d0353e82404379a89", + sha1 = "35f4b77f8e8339da192120ee0b037944b94b4194", unsign = True, ) From 69d4ad47d66562e27e6a61d5b0048fbca4a553c9 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 4 Sep 2019 18:38:06 +0200 Subject: [PATCH 5/9] Revert "Revert "GerritServer: Silence non-critical logs from JGit's FS"" This reverts commit 7e072d129acf7219521c2a2f7334907e45da4adf. Change-Id: I5569358cd673144eb4fae4a5fdaf5bbddc3b1cb6 --- java/com/google/gerrit/acceptance/GerritServer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/java/com/google/gerrit/acceptance/GerritServer.java b/java/com/google/gerrit/acceptance/GerritServer.java index a71a87c04c..a88d09c21a 100644 --- a/java/com/google/gerrit/acceptance/GerritServer.java +++ b/java/com/google/gerrit/acceptance/GerritServer.java @@ -246,6 +246,7 @@ public class GerritServer implements AutoCloseable { .put("org.eclipse.jgit.transport.PacketLineIn", Level.WARN) .put("org.eclipse.jgit.transport.PacketLineOut", Level.WARN) .put("org.eclipse.jgit.internal.storage.file.FileSnapshot", Level.WARN) + .put("org.eclipse.jgit.util.FS", Level.WARN) .build(); private static boolean forceLocalDisk() { From 4b64e05d143d35b26e0ccb8c35156fd2567eef4b Mon Sep 17 00:00:00 2001 From: Luca Milanesio Date: Wed, 4 Sep 2019 23:05:31 +0100 Subject: [PATCH 6/9] Convert NoteDb migrator output into chars Fix the NoteDb migration progress by converting its binary output into printable characters that can be easily understood by humans. Bug: Issue 11444 Change-Id: I6c2c6f036d8e5402ce72b7cdd53a4677b0f54521 --- .../com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java b/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java index ef157d6a10..ebec9c59df 100644 --- a/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java +++ b/java/com/google/gerrit/server/notedb/rebuild/NoteDbMigrator.java @@ -142,7 +142,7 @@ public class NoteDbMigrator implements AutoCloseable { logger.atInfo().log(outputBuffer.toString()); outputBuffer = new StringBuilder(); } else { - outputBuffer.append(b); + outputBuffer.append(Character.toChars(b)); } } } From c4fe1d7a938228c03c60c9b3b88f84f3e568cb96 Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Thu, 5 Sep 2019 01:07:38 +0200 Subject: [PATCH 7/9] Upgrade JGit to 5.3.5.201909031855-r Improvements in JGit 5.3.1-5.3.5: - extend FileSnapshot for packfiles to also use checksum to detect changes - include filekey file attribute (inode on *nix filesystems) when comparing FileSnapshots - optionally wait opening new packfile until it can't be racy anymore - fix FileSnapshot's consideration of file size - ObjectDirectory: fix closing of obsolete packs - measure FileStoreAttributes per filesystem - improve measuring file timestamp resolution - measure minimal racy interval - use Instant to increase resolution to 1us (limited by FileTime) - persist FileStoreAttributes - optional asynchronous measurement of FileStoreAttributes - directory - FileStore cache - cache user and system level gitconfig - fix supportsAtomicCreateNewFile default to true - fix non-deterministic hash of archives created by ArchiveCommand - reproduce racy atomic update in PackedBatchRefUpdate and fix it Change-Id: If9102b5e7e0ea529d9d3a99fd1f06b7be2d540e1 --- lib/jgit/jgit.bzl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/jgit/jgit.bzl b/lib/jgit/jgit.bzl index 0f52913d16..46ddab3ea8 100644 --- a/lib/jgit/jgit.bzl +++ b/lib/jgit/jgit.bzl @@ -1,6 +1,6 @@ load("//tools/bzl:maven_jar.bzl", "MAVEN_CENTRAL", "maven_jar") -_JGIT_VERS = "5.3.1.201904271842-r" +_JGIT_VERS = "5.3.5.201909031855-r" _DOC_VERS = _JGIT_VERS # Set to _JGIT_VERS unless using a snapshot @@ -40,25 +40,25 @@ def jgit_maven_repos(): name = "jgit-lib", artifact = "org.eclipse.jgit:org.eclipse.jgit:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "dba85014483315fa426259bc1b8ccda9373a624b", + sha1 = "f5e087859c805b7dc9c544714e9970f534791cf6", ) maven_jar( name = "jgit-servlet", artifact = "org.eclipse.jgit:org.eclipse.jgit.http.server:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "3287341fca859340a00b51cb5dd3b78b8e532b39", + sha1 = "25577326355c0ecd951f9987607606de6af089be", ) maven_jar( name = "jgit-archive", artifact = "org.eclipse.jgit:org.eclipse.jgit.archive:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "3585027e83fb44a5de2c10ae9ddbf976593bf080", + sha1 = "7ec97af1ffab2c2466570d7566e6748d1e48d7e8", ) maven_jar( name = "jgit-junit", artifact = "org.eclipse.jgit:org.eclipse.jgit.junit:" + _JGIT_VERS, repository = _JGIT_REPO, - sha1 = "3d9ba7e610d6ab5d08dcb1e4ba448b592a34de77", + sha1 = "f92c31856a700237be0ecfb4d5044fa0ca4671dc", ) def jgit_dep(name): From 69529436202601e94405ef630f7885963c11f59e Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 6 Sep 2019 12:08:32 +0900 Subject: [PATCH 8/9] UploadArchive: Use PacketLineIn.isEnd helper method The isEnd method is available since [1] and the END constant was deprecated in [2], both of which are included in JGit since version v5.4.0.201906121030-r. [1] https://git.eclipse.org/r/#/c/143171/ [2] https://git.eclipse.org/r/#/c/143176/ Change-Id: I995954fb54d7dfa0b0aa7729999e92d4bd5e4b92 --- java/com/google/gerrit/sshd/commands/UploadArchive.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/java/com/google/gerrit/sshd/commands/UploadArchive.java b/java/com/google/gerrit/sshd/commands/UploadArchive.java index a58e472d10..c25a1a8f66 100644 --- a/java/com/google/gerrit/sshd/commands/UploadArchive.java +++ b/java/com/google/gerrit/sshd/commands/UploadArchive.java @@ -139,7 +139,7 @@ public class UploadArchive extends AbstractGitCommand { PacketLineIn packetIn = new PacketLineIn(in); for (; ; ) { String s = packetIn.readString(); - if (isPacketLineEnd(s)) { + if (PacketLineIn.isEnd(s)) { break; } if (!s.startsWith(argCmd)) { @@ -163,12 +163,6 @@ public class UploadArchive extends AbstractGitCommand { } } - // JGit API depends on reference equality with sentinel. - @SuppressWarnings({"ReferenceEquality", "StringEquality"}) - private static boolean isPacketLineEnd(String s) { - return s == PacketLineIn.END; - } - @Override protected void runImpl() throws IOException, PermissionBackendException, Failure { PacketLineOut packetOut = new PacketLineOut(out); From 95c89ec8a04a97ab651676655d2463bef17786cb Mon Sep 17 00:00:00 2001 From: David Pursehouse Date: Fri, 6 Sep 2019 12:09:37 +0900 Subject: [PATCH 9/9] Stop using JGit's deprecated AnyObjectId.equals method The equals method was depecated in favor of isEqual in [1] which is included in JGit since version v5.4.1.201908211225-r. [1] https://git.eclipse.org/r/#/c/147315/ Change-Id: I5366437a04a75135fcd522e65b80be5a34d7c334 --- java/com/google/gerrit/server/edit/ChangeEditModifier.java | 4 ++-- java/com/google/gerrit/server/patch/PatchListLoader.java | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/java/com/google/gerrit/server/edit/ChangeEditModifier.java b/java/com/google/gerrit/server/edit/ChangeEditModifier.java index fcd38c3435..661e376299 100644 --- a/java/com/google/gerrit/server/edit/ChangeEditModifier.java +++ b/java/com/google/gerrit/server/edit/ChangeEditModifier.java @@ -371,7 +371,7 @@ public class ChangeEditModifier { if (optionalChangeEdit.isPresent()) { ChangeEdit changeEdit = optionalChangeEdit.get(); newTreeId = merge(repository, changeEdit, newTreeId); - if (ObjectId.equals(newTreeId, changeEdit.getEditCommit().getTree())) { + if (ObjectId.isEqual(newTreeId, changeEdit.getEditCommit().getTree())) { // Modifications are already contained in the change edit. return changeEdit; } @@ -474,7 +474,7 @@ public class ChangeEditModifier { treeCreator.addTreeModifications(treeModifications); ObjectId newTreeId = treeCreator.createNewTreeAndGetId(repository); - if (ObjectId.equals(newTreeId, baseCommit.getTree())) { + if (ObjectId.isEqual(newTreeId, baseCommit.getTree())) { throw new InvalidChangeOperationException("no changes were made"); } return newTreeId; diff --git a/java/com/google/gerrit/server/patch/PatchListLoader.java b/java/com/google/gerrit/server/patch/PatchListLoader.java index 08de537305..b639f96327 100644 --- a/java/com/google/gerrit/server/patch/PatchListLoader.java +++ b/java/com/google/gerrit/server/patch/PatchListLoader.java @@ -314,12 +314,12 @@ public class PatchListLoader implements Callable { } private static boolean areParentChild(RevCommit commitA, RevCommit commitB) { - return ObjectId.equals(commitA.getParent(0), commitB) - || ObjectId.equals(commitB.getParent(0), commitA); + return ObjectId.isEqual(commitA.getParent(0), commitB) + || ObjectId.isEqual(commitB.getParent(0), commitA); } private static boolean haveCommonParent(RevCommit commitA, RevCommit commitB) { - return ObjectId.equals(commitA.getParent(0), commitB.getParent(0)); + return ObjectId.isEqual(commitA.getParent(0), commitB.getParent(0)); } private static Set getTouchedFilePaths(PatchListEntry patchListEntry) {