Skip to content

blocking stub v2 server streaming calls sometimes require .read() to initiate request #12073

@benjaminp

Description

@benjaminp

If the channel is in an idle state when ClientCalls.blockingV2ServerStreamingCall is invoked, sending the request will be queued up in DelayedClientTransport. When the connection is set up, DelayedClientTransport will run all the deferred request initiation steps on the call executor:

Executor executor = defaultAppExecutor;
// createRealStream may be expensive. It will start real streams on the transport. If
// there are pending requests, they will be serialized too, which may be expensive. Since
// we are now on transport thread, we need to offload the work to an executor.
if (callOptions.getExecutor() != null) {
executor = callOptions.getExecutor();
}
Unfortunately, the call executor for the blocking v2 stubs is a ThreadSafeThreadlessExecutor, which means the headers and request aren't actually sent until the client calls .read() on the BlockingClientCall.

In contrast, the blocking v1 stub always sent the request as soon as possible.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions