diff --git a/stub/src/main/java/io/grpc/kotlin/CoroutineContextServerInterceptor.kt b/stub/src/main/java/io/grpc/kotlin/CoroutineContextServerInterceptor.kt index f81063eb..9d46dc54 100644 --- a/stub/src/main/java/io/grpc/kotlin/CoroutineContextServerInterceptor.kt +++ b/stub/src/main/java/io/grpc/kotlin/CoroutineContextServerInterceptor.kt @@ -40,6 +40,13 @@ abstract class CoroutineContextServerInterceptor : ServerInterceptor { */ abstract fun coroutineContext(call: ServerCall<*, *>, headers: Metadata): CoroutineContext + /** + * Override this function to insert a forwarding server call. + */ + open fun forward(call: ServerCall) :ServerCall { + return call + } + private inline fun withGrpcContext(context: GrpcContext, action: () -> R): R { val oldContext: GrpcContext = context.attach() return try { @@ -61,7 +68,7 @@ abstract class CoroutineContextServerInterceptor : ServerInterceptor { throw e } return withGrpcContext(GrpcContext.current().extendCoroutineContext(coroutineContext)) { - next.startCall(call, headers) + next.startCall(forward(call), headers) } } } \ No newline at end of file