mirror of https://github.com/grpc/grpc-java.git
stub: Add null check for responseObserver (#10083)
* stub:Add null check for responseObserver Fixes #10064
This commit is contained in:
parent
e89e0ccfee
commit
9d1e089c27
|
@ -73,6 +73,7 @@ public final class ClientCalls {
|
|||
*/
|
||||
public static <ReqT, RespT> void asyncUnaryCall(
|
||||
ClientCall<ReqT, RespT> call, ReqT req, StreamObserver<RespT> responseObserver) {
|
||||
checkNotNull(responseObserver, "responseObserver");
|
||||
asyncUnaryRequestCall(call, req, responseObserver, false);
|
||||
}
|
||||
|
||||
|
@ -86,6 +87,7 @@ public final class ClientCalls {
|
|||
*/
|
||||
public static <ReqT, RespT> void asyncServerStreamingCall(
|
||||
ClientCall<ReqT, RespT> call, ReqT req, StreamObserver<RespT> responseObserver) {
|
||||
checkNotNull(responseObserver, "responseObserver");
|
||||
asyncUnaryRequestCall(call, req, responseObserver, true);
|
||||
}
|
||||
|
||||
|
@ -102,6 +104,7 @@ public final class ClientCalls {
|
|||
public static <ReqT, RespT> StreamObserver<ReqT> asyncClientStreamingCall(
|
||||
ClientCall<ReqT, RespT> call,
|
||||
StreamObserver<RespT> responseObserver) {
|
||||
checkNotNull(responseObserver, "responseObserver");
|
||||
return asyncStreamingRequestCall(call, responseObserver, false);
|
||||
}
|
||||
|
||||
|
@ -116,6 +119,7 @@ public final class ClientCalls {
|
|||
*/
|
||||
public static <ReqT, RespT> StreamObserver<ReqT> asyncBidiStreamingCall(
|
||||
ClientCall<ReqT, RespT> call, StreamObserver<RespT> responseObserver) {
|
||||
checkNotNull(responseObserver, "responseObserver");
|
||||
return asyncStreamingRequestCall(call, responseObserver, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -503,6 +503,50 @@ public class ClientCallsTest {
|
|||
assertThat(requests).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForNullInAsyncUnaryCall() {
|
||||
NoopClientCall<Integer, String> call = new NoopClientCall<>();
|
||||
try {
|
||||
ClientCalls.asyncUnaryCall(call, Integer.valueOf(1), null);
|
||||
fail("Should have gotten an exception for the null responseObserver");
|
||||
} catch (NullPointerException e) {
|
||||
assertEquals("responseObserver", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForNullInBidiCall() {
|
||||
NoopClientCall<Integer, String> call = new NoopClientCall<>();
|
||||
try {
|
||||
ClientCalls.asyncBidiStreamingCall(call, null);
|
||||
fail("Should have gotten an exception for the null responseObserver");
|
||||
} catch (NullPointerException e) {
|
||||
assertEquals("responseObserver", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForNullInClientStreamCall() {
|
||||
NoopClientCall<Integer, String> call = new NoopClientCall<>();
|
||||
try {
|
||||
ClientCalls.asyncClientStreamingCall(call, null);
|
||||
fail("Should have gotten an exception for the null responseObserver");
|
||||
} catch (NullPointerException e) {
|
||||
assertEquals("responseObserver", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void checkForNullInServerStreamCall() {
|
||||
NoopClientCall<Integer, String> call = new NoopClientCall<>();
|
||||
try {
|
||||
ClientCalls.asyncServerStreamingCall(call, Integer.valueOf(1), null);
|
||||
fail("Should have gotten an exception for the null responseObserver");
|
||||
} catch (NullPointerException e) {
|
||||
assertEquals("responseObserver", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callStreamObserverPropagatesFlowControlRequestsToCall()
|
||||
throws Exception {
|
||||
|
|
Loading…
Reference in New Issue