Interface ClientStream<RequestT> (2.55.0)

publicinterfaceClientStream<RequestT>

A wrapper used to send requests to the server.

After sending requests, users must either call#closeSend() or#closeSendWithError(Throwable) on the stream. The error, if any, will be propagated to the server.

Example usage:

ClientStream<String>stream=...;List<String>lines=getLinesFromFile();for(Stringline:lines){stream.send(line);}stream.closeSend();

Type Parameter

NameDescription
RequestT

Methods

closeSend()

publicabstractvoidcloseSend()

Closes the stream. If called, this must be the last call on thisClientStream.

Note that ifclose() itself throws, a further call tocloseSendWithError is not allowed.

closeSendWithError(Throwable t)

publicabstractvoidcloseSendWithError(Throwablet)

Closes the stream with an error. If called, this must be the last call on this ClientStream.

Parameter
NameDescription
tThrowable

isSendReady()

publicabstractbooleanisSendReady()

Reports whether a new request can be sent without excessive buffering.

This is only an optimization hint to the user. It is correct, if suboptimal, to call send ifisSendReady returns false.

Returns
TypeDescription
boolean

send(RequestT request)

publicabstractvoidsend(RequestTrequest)

Sends a request to the server. It is an error to call this if the stream is already closed.

Parameter
NameDescription
requestRequestT

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-17 UTC.