diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2024-09-24 10:51:22 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2024-09-25 16:43:52 +0200 |
commit | 56a5db65b3e6c0c838b29071323332439dbbc08f (patch) | |
tree | 9483725034365153165e8b97e16110c91e49f286 | |
parent | f9cc863220814d70440766c3ac80c61bc69cae4f (diff) | |
download | jgit-stable-6.6.tar.gz jgit-stable-6.6.zip |
AdvertisedRequestValidator: fix WantNotValidException caused by racestable-6.6
Fetch with protocol V2 failed under the following conditions
- fetch uses bidirectional protocol (git, ssh) which uses a shortcut
to determine invalid wants
- not all wants are advertised
- race condition: wanted ref is updated during fetch by another thread
after the thread serving upload-pack determined wants and before it
checks not advertised wants
Fix this by calling
`new ReachableCommitRequestValidator().checkWants(up, wants)`
instead of throwing WantNotValidException in [1]
if this race happened in the same way like it's done for unidirectional
protocols (http) [2].
[1] https://github.com/eclipse-jgit/jgit/blob/stable-6.10/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java#L2002
[2] https://github.com/eclipse-jgit/jgit/blob/stable-6.10/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java#L2000
Bug: jgit-48
Change-Id: I32f28502923815dc49781aab5d810c9afbe7e7e6
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java | 5 |
1 files changed, 2 insertions, 3 deletions
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 3264f556fa..8b97ee10ca 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/UploadPack.java @@ -1968,10 +1968,9 @@ public class UploadPack implements Closeable { @Override public void checkWants(UploadPack up, List<ObjectId> wants) throws PackProtocolException, IOException { - if (!up.isBiDirectionalPipe()) + if (!up.isBiDirectionalPipe() || !wants.isEmpty()) { new ReachableCommitRequestValidator().checkWants(up, wants); - else if (!wants.isEmpty()) - throw new WantNotValidException(wants.iterator().next()); + } } } |