From 1e932c2e5289e965dea0314b230b6d3d94ea3bdb Mon Sep 17 00:00:00 2001 From: Matthias Sohn Date: Wed, 12 Jan 2022 18:37:02 +0100 Subject: [PATCH 1/2] Complete update to servlet api 4.0.0 Ibd0240cf7ad updated servlet-api to 4.0.0 only partially for the osgi-based build in Eclipse. Complete this by updating dependencies also in maven and bazel build. Change-Id: Ic4c3eb78c538007ca2177f6109d415147e58eabe --- WORKSPACE | 4 ++-- pom.xml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/WORKSPACE b/WORKSPACE index f78a159fb..51a815e2f 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -171,8 +171,8 @@ maven_jar( maven_jar( name = "servlet-api", - artifact = "javax.servlet:javax.servlet-api:3.1.0", - sha1 = "3cd63d075497751784b2fa84be59432f4905bf7c", + artifact = "javax.servlet:javax.servlet-api:4.0.0", + sha1 = "60200affc2fe0165136ed3690faf00b66aed581a", ) maven_jar( diff --git a/pom.xml b/pom.xml index 7ae2c21f8..c486569fa 100644 --- a/pom.xml +++ b/pom.xml @@ -161,7 +161,7 @@ 2.33 1.21 4.3.1 - 3.1.0 + 4.0.0 10.0.6 0.15.3 4.5.13 From 78d4fb1ca00149a700f586357139f08efaa29ff6 Mon Sep 17 00:00:00 2001 From: Marcin Czech Date: Wed, 22 Dec 2021 17:42:36 +0100 Subject: [PATCH 2/2] UploadPack v2 protocol: Stop negotiation for orphan refs The fetch of a single orphan ref (for example Gerrit meta ref: refs/changes/21/21/meta) did not stop the negotiation so client had to advertise all refs. This impacts the fetch performance on repositories with a large number of refs (for example on Gerrit repository it takes 20 seconds to fetch meta ref comparing to 1.2 second to fetch ref with parent). To avoid this issue UploadPack, used on the server side, now checks if all `want` refs have parents, if not this means that client doesn't need any extra objects, hence the server responds with `ready` and finishes the negotiation phase. Bug: 577937 Change-Id: Ia3001b400b415d5cf6aae45e72345ca08d3af058 --- .../jgit/transport/UploadPackTest.java | 55 +++++++++++++++++++ .../eclipse/jgit/transport/UploadPack.java | 5 ++ 2 files changed, 60 insertions(+) diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java index 5045e9464..3958de2d9 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/transport/UploadPackTest.java @@ -998,6 +998,61 @@ public void testV2FetchClientStopsNegotiation() throws Exception { assertTrue(client.getObjectDatabase().has(barChild.toObjectId())); } + @Test + public void testV2FetchServerStopsNegotiationForRefWithoutParents() + throws Exception { + RevCommit fooCommit = remote.commit().message("x").create(); + RevCommit barCommit = remote.commit().message("y").create(); + remote.update("refs/changes/01/1/1", fooCommit); + remote.update("refs/changes/02/2/1", barCommit); + + ByteArrayInputStream recvStream = uploadPackV2("command=fetch\n", + PacketLineIn.delimiter(), + "want " + fooCommit.toObjectId().getName() + "\n", + "have " + barCommit.toObjectId().getName() + "\n", + PacketLineIn.end()); + PacketLineIn pckIn = new PacketLineIn(recvStream); + + assertThat(pckIn.readString(), is("acknowledgments")); + assertThat(pckIn.readString(), + is("ACK " + barCommit.toObjectId().getName())); + assertThat(pckIn.readString(), is("ready")); + assertTrue(PacketLineIn.isDelimiter(pckIn.readString())); + assertThat(pckIn.readString(), is("packfile")); + parsePack(recvStream); + assertTrue(client.getObjectDatabase().has(fooCommit.toObjectId())); + } + + @Test + public void testV2FetchServerDoesNotStopNegotiationWhenOneRefWithoutParentAndOtherWithParents() + throws Exception { + RevCommit fooCommit = remote.commit().message("x").create(); + RevCommit barParent = remote.commit().message("y").create(); + RevCommit barChild = remote.commit().message("y").parent(barParent) + .create(); + RevCommit fooBarParent = remote.commit().message("z").create(); + RevCommit fooBarChild = remote.commit().message("y") + .parent(fooBarParent) + .create(); + remote.update("refs/changes/01/1/1", fooCommit); + remote.update("refs/changes/02/2/1", barChild); + remote.update("refs/changes/03/3/1", fooBarChild); + + ByteArrayInputStream recvStream = uploadPackV2("command=fetch\n", + PacketLineIn.delimiter(), + "want " + fooCommit.toObjectId().getName() + "\n", + "want " + barChild.toObjectId().getName() + "\n", + "want " + fooBarChild.toObjectId().getName() + "\n", + "have " + fooBarParent.toObjectId().getName() + "\n", + PacketLineIn.end()); + PacketLineIn pckIn = new PacketLineIn(recvStream); + + assertThat(pckIn.readString(), is("acknowledgments")); + assertThat(pckIn.readString(), + is("ACK " + fooBarParent.toObjectId().getName())); + assertTrue(PacketLineIn.isEnd(pckIn.readString())); + } + @Test public void testV2FetchThinPack() throws Exception { String commonInBlob = "abcdefghijklmnopqrstuvwxyz"; diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java index 9fda63928..63deff2d9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -2103,6 +2103,11 @@ private boolean wantSatisfied(RevObject want) throws IOException { if (want.has(SATISFIED)) return true; + if (((RevCommit) want).getParentCount() == 0) { + want.add(SATISFIED); + return true; + } + walk.resetRetain(SAVE); walk.markStart((RevCommit) want); if (oldestTime != 0)