summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorJonathan Nieder <jrn@google.com>2016-08-15 15:40:49 -0400
committerGerrit Code Review @ Eclipse.org <gerrit@eclipse.org>2016-08-15 15:40:51 -0400
commitca2bf6fc183ce2ccefeb5a8bf0b59340da1529aa (patch)
tree46dae2fce8f9a96514fa586535cdf816ba46943a /org.eclipse.jgit
parent81ba2bece71aa1382cb4428dd6d7dec9e4ceddb6 (diff)
parenta6c0d829b917c3a23efe8e7bc03c7dd5e9e7ee14 (diff)
downloadjgit-ca2bf6fc183ce2ccefeb5a8bf0b59340da1529aa.tar.gz
jgit-ca2bf6fc183ce2ccefeb5a8bf0b59340da1529aa.zip
Merge "BaseReceivePack: null and IllegalStateException cases for getPushOptions"
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java22
1 files changed, 19 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
index b9923b95e2..4bd3af2f87 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java
@@ -69,6 +69,7 @@ import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
+import org.eclipse.jgit.annotations.Nullable;
import org.eclipse.jgit.errors.InvalidObjectIdException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.errors.PackProtocolException;
@@ -845,9 +846,11 @@ public abstract class BaseReceivePack {
}
/**
- * Gets the list of string options associated with this push.
+ * Gets an unmodifiable view of the option strings associated with the push.
*
- * @return pushOptions
+ * @return an unmodifiable view of pushOptions, or null (if pushOptions is).
+ * @throws IllegalStateException
+ * if allowPushOptions has not been set to true.
* @throws RequestNotYetReadException
* if the client's request has not yet been read from the wire,
* so we do not know if they expect push options. Note that the
@@ -855,10 +858,23 @@ public abstract class BaseReceivePack {
* been read.
* @since 4.5
*/
- public List<String> getPushOptions() throws RequestNotYetReadException {
+ @Nullable
+ public List<String> getPushOptions() {
+ if (!allowPushOptions) {
+ // Reading push options without a prior setAllowPushOptions(true)
+ // call doesn't make sense.
+ throw new IllegalStateException();
+ }
if (enabledCapabilities == null) {
+ // Push options are not available until receive() has been called.
throw new RequestNotYetReadException();
}
+ if (pushOptions == null) {
+ // The client doesn't support push options. Return null to
+ // distinguish this from the case where the client declared support
+ // for push options and sent an empty list of them.
+ return null;
+ }
return Collections.unmodifiableList(pushOptions);
}