aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/GRPCClient/private/GRPCChannel.m
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-10-20 09:40:22 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-10-20 09:40:22 -0700
commit4186405287a6944e7b1eb59dcae5524ea2db674d (patch)
tree724d915693ddccd9dfd122e10544bf44f5a3d862 /src/objective-c/GRPCClient/private/GRPCChannel.m
parent5e3e744d448c8cd1271cae7e8d40d3bdeaff762f (diff)
GRPCChannel input parameter sanity check
Diffstat (limited to 'src/objective-c/GRPCClient/private/GRPCChannel.m')
-rw-r--r--src/objective-c/GRPCClient/private/GRPCChannel.m13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m
index 6bd852fd0d..6b5d1fe071 100644
--- a/src/objective-c/GRPCClient/private/GRPCChannel.m
+++ b/src/objective-c/GRPCClient/private/GRPCChannel.m
@@ -150,14 +150,17 @@ NSTimeInterval kChannelDestroyDelay = 30;
}
- (grpc_call *)unmanagedCallWithPath:(NSString *)path
- completionQueue:(nonnull GRPCCompletionQueue *)queue
+ completionQueue:(GRPCCompletionQueue *)queue
callOptions:(GRPCCallOptions *)callOptions {
+ NSAssert(path.length, @"path must not be empty.");
+ NSAssert(queue, @"completionQueue must not be empty.");
+ NSAssert(callOptions, @"callOptions must not be empty.");
__block grpc_call *call = nil;
dispatch_sync(_dispatchQueue, ^{
if (self->_unmanagedChannel) {
NSString *serverAuthority = callOptions.serverAuthority;
NSTimeInterval timeout = callOptions.timeout;
- GPR_ASSERT(timeout >= 0);
+ NSAssert(timeout >= 0, @"Invalid timeout");
grpc_slice host_slice = grpc_empty_slice();
if (serverAuthority) {
host_slice = grpc_slice_from_copied_string(serverAuthority.UTF8String);
@@ -216,8 +219,12 @@ NSTimeInterval kChannelDestroyDelay = 30;
});
}
-- (nullable instancetype)initWithUnmanagedChannel:(nullable grpc_channel *)unmanagedChannel
+- (nullable instancetype)initWithUnmanagedChannel:(grpc_channel * _Nullable)unmanagedChannel
configuration:(GRPCChannelConfiguration *)configuration {
+ NSAssert(configuration, @"Configuration must not be empty.");
+ if (!unmanagedChannel) {
+ return nil;
+ }
if ((self = [super init])) {
_unmanagedChannel = unmanagedChannel;
_configuration = [configuration copy];