BaseReceivePack: null and IllegalStateException cases for getPushOptions
Change-Id: I5c6790719991931d615d821c900bfd90a20e540b Signed-off-by: Dan Wang <dwwang@google.com>
This commit is contained in:
parent
7f9fb80002
commit
a6c0d829b9
|
@ -69,6 +69,7 @@
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
|
import org.eclipse.jgit.annotations.Nullable;
|
||||||
import org.eclipse.jgit.errors.InvalidObjectIdException;
|
import org.eclipse.jgit.errors.InvalidObjectIdException;
|
||||||
import org.eclipse.jgit.errors.MissingObjectException;
|
import org.eclipse.jgit.errors.MissingObjectException;
|
||||||
import org.eclipse.jgit.errors.PackProtocolException;
|
import org.eclipse.jgit.errors.PackProtocolException;
|
||||||
|
@ -845,9 +846,11 @@ public boolean isQuiet() throws RequestNotYetReadException {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
* @throws RequestNotYetReadException
|
||||||
* if the client's request has not yet been read from the wire,
|
* 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
|
* so we do not know if they expect push options. Note that the
|
||||||
|
@ -855,10 +858,23 @@ public boolean isQuiet() throws RequestNotYetReadException {
|
||||||
* been read.
|
* been read.
|
||||||
* @since 4.5
|
* @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) {
|
if (enabledCapabilities == null) {
|
||||||
|
// Push options are not available until receive() has been called.
|
||||||
throw new RequestNotYetReadException();
|
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);
|
return Collections.unmodifiableList(pushOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue