api: expose if waitForReady has been set on CallOptions
diff --git a/api/src/main/java/io/grpc/CallOptions.java b/api/src/main/java/io/grpc/CallOptions.java
index 3753f7c..17b065e 100644
--- a/api/src/main/java/io/grpc/CallOptions.java
+++ b/api/src/main/java/io/grpc/CallOptions.java
@@ -69,7 +69,8 @@
/**
* Opposite to fail fast.
*/
- private boolean waitForReady;
+ @Nullable
+ private Boolean waitForReady;
@Nullable
private Integer maxInboundMessageSize;
@@ -154,7 +155,7 @@
*/
public CallOptions withWaitForReady() {
CallOptions newOptions = new CallOptions(this);
- newOptions.waitForReady = true;
+ newOptions.waitForReady = Boolean.TRUE;
return newOptions;
}
@@ -164,7 +165,7 @@
*/
public CallOptions withoutWaitForReady() {
CallOptions newOptions = new CallOptions(this);
- newOptions.waitForReady = false;
+ newOptions.waitForReady = Boolean.FALSE;
return newOptions;
}
@@ -369,6 +370,10 @@
* calls and 'wait for ready' is the opposite to it.
*/
public boolean isWaitForReady() {
+ return Boolean.TRUE.equals(waitForReady);
+ }
+
+ Boolean getWaitForReady() {
return waitForReady;
}
diff --git a/api/src/main/java/io/grpc/InternalCallOptions.java b/api/src/main/java/io/grpc/InternalCallOptions.java
new file mode 100644
index 0000000..92546f0
--- /dev/null
+++ b/api/src/main/java/io/grpc/InternalCallOptions.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2019 The gRPC Authors
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package io.grpc;
+
+/**
+ * Internal accessor for {@link CallOptions}.
+ */
+@Internal
+public final class InternalCallOptions {
+ private InternalCallOptions() {}
+
+ /**
+ * Gets the waitForReady bit or {@code null} if it was never set.
+ */
+ public static Boolean getWaitForReady(CallOptions callOptions) {
+ return callOptions.getWaitForReady();
+ }
+}
diff --git a/api/src/test/java/io/grpc/CallOptionsTest.java b/api/src/test/java/io/grpc/CallOptionsTest.java
index 31a0aff..d4ef1fb 100644
--- a/api/src/test/java/io/grpc/CallOptionsTest.java
+++ b/api/src/test/java/io/grpc/CallOptionsTest.java
@@ -24,6 +24,8 @@
import static java.util.concurrent.TimeUnit.MINUTES;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
import static java.util.concurrent.TimeUnit.SECONDS;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.fail;
import static org.mockito.Mockito.mock;
@@ -234,6 +236,13 @@
}
}
+ @Test
+ public void getWaitForReady() {
+ assertNull(CallOptions.DEFAULT.getWaitForReady());
+ assertSame(CallOptions.DEFAULT.withWaitForReady().getWaitForReady(), Boolean.TRUE);
+ assertSame(CallOptions.DEFAULT.withoutWaitForReady().getWaitForReady(), Boolean.FALSE);
+ }
+
// Only used in noStrayModifications()
// TODO(carl-mastrangelo): consider making a CallOptionsSubject for Truth.
private static boolean equal(CallOptions o1, CallOptions o2) {