diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java index a960b4a4b..fbb58ccbc 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchRequest.java @@ -42,6 +42,8 @@ */ package org.eclipse.jgit.transport; +import static java.util.Objects.requireNonNull; + import java.util.Set; import org.eclipse.jgit.annotations.NonNull; @@ -76,19 +78,14 @@ abstract class FetchRequest { * @param clientCapabilities * capabilities sent in the request */ - FetchRequest(Set wantIds, int depth, - Set clientShallowCommits, long filterBlobLimit, - Set clientCapabilities) { - if (wantIds == null || clientShallowCommits == null - || clientCapabilities == null) { - throw new NullPointerException(); - } - - this.wantIds = wantIds; + FetchRequest(@NonNull Set wantIds, int depth, + @NonNull Set clientShallowCommits, long filterBlobLimit, + @NonNull Set clientCapabilities) { + this.wantIds = requireNonNull(wantIds); this.depth = depth; - this.clientShallowCommits = clientShallowCommits; + this.clientShallowCommits = requireNonNull(clientShallowCommits); this.filterBlobLimit = filterBlobLimit; - this.clientCapabilities = clientCapabilities; + this.clientCapabilities = requireNonNull(clientCapabilities); } /** diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java index a40c73471..22ad629e3 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV0Request.java @@ -46,6 +46,7 @@ import java.util.Collection; import java.util.HashSet; import java.util.Set; +import org.eclipse.jgit.annotations.NonNull; import org.eclipse.jgit.lib.ObjectId; /** @@ -53,9 +54,9 @@ import org.eclipse.jgit.lib.ObjectId; */ final class FetchV0Request extends FetchRequest { - FetchV0Request(Set wantIds, int depth, - Set clientShallowCommits, long filterBlobLimit, - Set clientCapabilities) { + FetchV0Request(@NonNull Set wantIds, int depth, + @NonNull Set clientShallowCommits, long filterBlobLimit, + @NonNull Set clientCapabilities) { super(wantIds, depth, clientShallowCommits, filterBlobLimit, clientCapabilities); } @@ -64,13 +65,13 @@ final class FetchV0Request extends FetchRequest { int depth; - Set wantIds = new HashSet<>(); + final Set wantIds = new HashSet<>(); - Set clientShallowCommits = new HashSet<>(); + final Set clientShallowCommits = new HashSet<>(); long filterBlobLimit = -1; - Set clientCaps = new HashSet<>(); + final Set clientCaps = new HashSet<>(); /** * @param objectId diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java index 7d84b19a4..dcca522ae 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/FetchV2Request.java @@ -42,6 +42,8 @@ */ package org.eclipse.jgit.transport; +import static java.util.Objects.requireNonNull; + import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -71,16 +73,18 @@ public final class FetchV2Request extends FetchRequest { private final boolean doneReceived; - private FetchV2Request(List peerHas, - TreeMap wantedRefs, Set wantIds, - Set clientShallowCommits, int deepenSince, - List deepenNotRefs, int depth, long filterBlobLimit, - boolean doneReceived, Set clientCapabilities) { + FetchV2Request(@NonNull List peerHas, + @NonNull TreeMap wantedRefs, + @NonNull Set wantIds, + @NonNull Set clientShallowCommits, int deepenSince, + @NonNull List deepenNotRefs, int depth, + long filterBlobLimit, + boolean doneReceived, @NonNull Set clientCapabilities) { super(wantIds, depth, clientShallowCommits, filterBlobLimit, clientCapabilities); - this.peerHas = peerHas; - this.wantedRefs = wantedRefs; + this.peerHas = requireNonNull(peerHas); + this.wantedRefs = requireNonNull(wantedRefs); this.deepenSince = deepenSince; - this.deepenNotRefs = deepenNotRefs; + this.deepenNotRefs = requireNonNull(deepenNotRefs); this.doneReceived = doneReceived; } @@ -134,17 +138,17 @@ public final class FetchV2Request extends FetchRequest { /** A builder for {@link FetchV2Request}. */ static final class Builder { - List peerHas = new ArrayList<>(); + final List peerHas = new ArrayList<>(); - TreeMap wantedRefs = new TreeMap<>(); + final TreeMap wantedRefs = new TreeMap<>(); - Set wantIds = new HashSet<>(); + final Set wantIds = new HashSet<>(); - Set clientShallowCommits = new HashSet<>(); + final Set clientShallowCommits = new HashSet<>(); - List deepenNotRefs = new ArrayList<>(); + final List deepenNotRefs = new ArrayList<>(); - Set clientCapabilities = new HashSet<>(); + final Set clientCapabilities = new HashSet<>(); int depth;