Top Description Inners Fields Constructors Methods
io.grpc

public final Class Status

extends Object
Class Inheritance
Annotations
@Immutable
@CheckReturnValue
Static Imports
com.google.common.base.Charsets.US_ASCII, .Charsets.UTF_8, .Preconditions.checkNotNull, .Throwables.getStackTraceAsString

Defines the status of an operation by providing a standard Code in conjunction with an optional descriptive message. Instances of Status are created by starting with the template for the appropriate Status.Code and supplementing it with additional information: Status.NOT_FOUND.withDescription("Could not find 'important_file.txt'");

For clients, every remote call will return a status on completion. In the case of errors this status may be propagated to blocking stubs as a RuntimeException or to a listener as an explicit parameter.

Similarly servers can report a status by throwing StatusRuntimeException or by passing the status to a callback.

Utility functions are provided to convert a status to an exception and to extract them back out.

Extended descriptions, including a list of codes that should not be generated by the library, can be found at doc/statuscodes.md

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
Status.Code

The set of canonical status codes.

private static class
private static class

Field Summary

Modifier and TypeField and Description
public static final Status
ABORTED

The operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc. See Code#ABORTED.

public static final Status
ALREADY_EXISTS

Some entity that we attempted to create (e.g., file or directory) already exists.

public static final Status
CANCELLED

The operation was cancelled (typically by the caller).

private final Throwable
private final Status.Code
pack-priv static final Metadata.Key<Status>
CODE_KEY

Key to bind status code to trailing metadata.

public static final Status
DATA_LOSS

Unrecoverable data loss or corruption.

public static final Status
DEADLINE_EXCEEDED

Deadline expired before operation could complete.

private final String
private static final boolean
public static final Status
FAILED_PRECONDITION

Operation was rejected because the system is not in a state required for the operation's execution.

public static final Status
INTERNAL

Internal errors.

public static final Status
INVALID_ARGUMENT

Client specified an invalid argument.

pack-priv static final Metadata.Key<String>
MESSAGE_KEY

Key to bind status message to trailing metadata.

public static final Status
NOT_FOUND

Some requested entity (e.g., file or directory) was not found.

public static final Status
OK

The operation completed successfully.

public static final Status
OUT_OF_RANGE

Operation was attempted past the valid range.

public static final Status
PERMISSION_DENIED

The caller does not have permission to execute the specified operation.

public static final Status
RESOURCE_EXHAUSTED

Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.

private static final List<Status>
private static final Metadata.TrustedAsciiMarshaller<String>
STATUS_MESSAGE_MARSHALLER

Marshals status messages for (MESSAGE_KEY.

private static final String
public static final Status
UNAUTHENTICATED

The request does not have valid authentication credentials for the operation.

public static final Status
UNAVAILABLE

The service is currently unavailable.

public static final Status
UNIMPLEMENTED

Operation is not implemented or not supported/enabled in this service.

public static final Status
UNKNOWN

Unknown error.

Constructor Summary

AccessConstructor and Description
private
private
Status(Status.Code code, String description, Throwable cause)

Method Summary

Modifier and TypeMethod and Description
public StatusException
asException()

Convert this Status to an Exception.

public StatusException
asException(Metadata trailers)

Same as asException() but includes the provided trailers in the returned exception.

public StatusRuntimeException
public StatusRuntimeException
asRuntimeException(Metadata trailers)

Same as asRuntimeException() but includes the provided trailers in the returned exception.

public Status
augmentDescription(String additionalDetail)

Create a derived instance of Status augmenting the current description with additional detail.

private static List<Status>
public boolean
equals(Object
the reference object with which to compare.
obj
)

Overrides java.lang.Object.equals.

Equality on Statuses is not well defined.
pack-priv static String
public static Status
fromCode(Status.Code code)

Return a Status given a canonical error Code object.

public static Status
fromCodeValue(int codeValue)

Return a Status given a canonical error Code value.

private static Status
fromCodeValue(byte[] asciiCodeValue)

private static Status
fromCodeValueSlow(byte[] asciiCodeValue)

public static Status

Returns:

non-null status
fromThrowable
(Throwable t)

Extract an error Status from the causal chain of a Throwable.

public Throwable
getCause()

The underlying cause of an error.

public Status.Code
getCode()

The canonical status code.

public String
getDescription()

A description of this status for human consumption.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Hash codes on Statuses are not well defined.
public boolean
isOk()

Is this status OK, i.e., not an error.

public String
toString()

Overrides java.lang.Object.toString.

A string representation of the status useful for debugging.
public static Metadata

Returns:

the trailers or null if not found.
trailersFromThrowable
(Throwable t)

Extract an error trailers from the causal chain of a Throwable.

public Status
withCause(Throwable cause)

Create a derived instance of Status with the given cause.

public Status
withDescription(String description)

Create a derived instance of Status with the given description.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

ABORTEDback to summary
public static final Status ABORTED

The operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc. See Code#ABORTED.

ALREADY_EXISTSback to summary
public static final Status ALREADY_EXISTS

Some entity that we attempted to create (e.g., file or directory) already exists.

CANCELLEDback to summary
public static final Status CANCELLED

The operation was cancelled (typically by the caller).

causeback to summary
private final Throwable cause
codeback to summary
private final Status.Code code
CODE_KEYback to summary
pack-priv static final Metadata.Key<Status> CODE_KEY

Key to bind status code to trailing metadata.

DATA_LOSSback to summary
public static final Status DATA_LOSS

Unrecoverable data loss or corruption.

DEADLINE_EXCEEDEDback to summary
public static final Status DEADLINE_EXCEEDED

Deadline expired before operation could complete. See Code#DEADLINE_EXCEEDED.

descriptionback to summary
private final String description
FAIL_ON_EQUALS_FOR_TESTback to summary
private static final boolean FAIL_ON_EQUALS_FOR_TEST
FAILED_PRECONDITIONback to summary
public static final Status FAILED_PRECONDITION

Operation was rejected because the system is not in a state required for the operation's execution. See Code#FAILED_PRECONDITION.

INTERNALback to summary
public static final Status INTERNAL

Internal errors. See Code#INTERNAL.

INVALID_ARGUMENTback to summary
public static final Status INVALID_ARGUMENT

Client specified an invalid argument. See Code#INVALID_ARGUMENT.

MESSAGE_KEYback to summary
pack-priv static final Metadata.Key<String> MESSAGE_KEY

Key to bind status message to trailing metadata.

NOT_FOUNDback to summary
public static final Status NOT_FOUND

Some requested entity (e.g., file or directory) was not found.

OKback to summary
public static final Status OK

The operation completed successfully.

OUT_OF_RANGEback to summary
public static final Status OUT_OF_RANGE

Operation was attempted past the valid range. See Code#OUT_OF_RANGE.

PERMISSION_DENIEDback to summary
public static final Status PERMISSION_DENIED

The caller does not have permission to execute the specified operation. See Code#PERMISSION_DENIED.

RESOURCE_EXHAUSTEDback to summary
public static final Status RESOURCE_EXHAUSTED

Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.

STATUS_LISTback to summary
private static final List<Status> STATUS_LIST
STATUS_MESSAGE_MARSHALLERback to summary
private static final Metadata.TrustedAsciiMarshaller<String> STATUS_MESSAGE_MARSHALLER

Marshals status messages for (MESSAGE_KEY. gRPC does not use binary coding of status messages by default, which makes sending arbitrary strings difficult. This marshaller uses ASCII printable characters by default, and percent encodes (e.g. %0A) all non ASCII bytes. This leads to normal text being mostly readable (especially useful for debugging), and special text still being sent.

By default, the HTTP spec says that header values must be encoded using a strict subset of ASCII (See RFC 7230 section 3.2.6). HTTP/2 HPACK allows use of arbitrary binary headers, but we do not use them for interoperating with existing HTTP/1.1 code. Since the grpc-message is encoded to such a header, it needs to not use forbidden characters.

This marshaller works by converting the passed in string into UTF-8, checking to see if each individual byte is an allowable byte, and then either percent encoding or passing it through. When percent encoding, the byte is converted into hexadecimal notation with a '%' prepended.

When unmarshalling, bytes are passed through unless they match the "%XX" pattern. If they do match, the unmarshaller attempts to convert them back into their original UTF-8 byte sequence. After the input header bytes are converted into UTF-8 bytes, the new byte array is reinterpretted back as a string.

TEST_EQUALS_FAILURE_PROPERTYback to summary
private static final String TEST_EQUALS_FAILURE_PROPERTY
UNAUTHENTICATEDback to summary
public static final Status UNAUTHENTICATED

The request does not have valid authentication credentials for the operation.

UNAVAILABLEback to summary
public static final Status UNAVAILABLE

The service is currently unavailable. See Code#UNAVAILABLE.

UNIMPLEMENTEDback to summary
public static final Status UNIMPLEMENTED

Operation is not implemented or not supported/enabled in this service.

UNKNOWNback to summary
public static final Status UNKNOWN

Unknown error. See Code#UNKNOWN.

Constructor Detail

Statusback to summary
private Status(Status.Code code)
Statusback to summary
private Status(Status.Code code, String description, Throwable cause)

Method Detail

asExceptionback to summary
public StatusException asException()

Convert this Status to an Exception. Use fromThrowable to recover this Status instance when the returned exception is in the causal chain.

asExceptionback to summary
public StatusException asException(Metadata trailers)

Same as asException() but includes the provided trailers in the returned exception.

asRuntimeExceptionback to summary
public StatusRuntimeException asRuntimeException()

Convert this Status to a RuntimeException. Use fromThrowable to recover this Status instance when the returned exception is in the causal chain.

asRuntimeExceptionback to summary
public StatusRuntimeException asRuntimeException(Metadata trailers)

Same as asRuntimeException() but includes the provided trailers in the returned exception.

augmentDescriptionback to summary
public Status augmentDescription(String additionalDetail)

Create a derived instance of Status augmenting the current description with additional detail. Leading and trailing whitespace may be removed; this may change in the future.

buildStatusListback to summary
private static List<Status> buildStatusList()
equalsback to summary
public boolean equals(Object obj)

Overrides java.lang.Object.equals.

Equality on Statuses is not well defined. Instead, do comparison based on their Code with getCode. The description and cause of the Status are unlikely to be stable, and additional fields may be added to Status in the future.

Parameters
obj:Object

Doc from java.lang.Object.equals.

the reference object with which to compare.

Returns:boolean

Doc from java.lang.Object.equals.

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
formatThrowableMessageback to summary
pack-priv static String formatThrowableMessage(Status status)
fromCodeback to summary
public static Status fromCode(Status.Code code)

Return a Status given a canonical error Code object.

fromCodeValueback to summary
public static Status fromCodeValue(int codeValue)

Return a Status given a canonical error Code value.

fromCodeValueback to summary
private static Status fromCodeValue(byte[] asciiCodeValue)
fromCodeValueSlowback to summary
private static Status fromCodeValueSlow(byte[] asciiCodeValue)
Annotations
@SuppressWarnings:fallthrough
fromThrowableback to summary
public static Status fromThrowable(Throwable t)

Extract an error Status from the causal chain of a Throwable. If no status can be found, a status is created with Code#UNKNOWN as its code and t as its cause.

Returns:Status

non-null status

getCauseback to summary
public Throwable getCause()

The underlying cause of an error. Note that the cause is not transmitted from server to client.

Annotations
@Nullable
getCodeback to summary
public Status.Code getCode()

The canonical status code.

getDescriptionback to summary
public String getDescription()

A description of this status for human consumption.

Annotations
@Nullable
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Hash codes on Statuses are not well defined.

Returns:int

Doc from java.lang.Object.hashCode.

a hash code value for this object.

Annotations
@Override
See Also
equals
isOkback to summary
public boolean isOk()

Is this status OK, i.e., not an error.

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

A string representation of the status useful for debugging.

Returns:String

Doc from java.lang.Object.toString.

a string representation of the object.

Annotations
@Override
trailersFromThrowableback to summary
public static Metadata trailersFromThrowable(Throwable t)

Extract an error trailers from the causal chain of a Throwable.

Returns:Metadata

the trailers or null if not found.

Annotations
@Nullable
withCauseback to summary
public Status withCause(Throwable cause)

Create a derived instance of Status with the given cause. However, the cause is not transmitted from server to client.

withDescriptionback to summary
public Status withDescription(String description)

Create a derived instance of Status with the given description. Leading and trailing whitespace may be removed; this may change in the future.

io.grpc back to summary

public final Enum Status.Code

extends Enum<Status.Code>
Class Inheritance

The set of canonical status codes. If new codes are added over time they must choose a numerical value that does not collide with any previously used value.

Field Summary

Modifier and TypeField and Description
public static final Status.Code
ABORTED

The operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.

See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE.

public static final Status.Code
ALREADY_EXISTS

Some entity that we attempted to create (e.g., file or directory) already exists.

public static final Status.Code
CANCELLED

The operation was cancelled (typically by the caller).

public static final Status.Code
DATA_LOSS

Unrecoverable data loss or corruption.

public static final Status.Code
DEADLINE_EXCEEDED

Deadline expired before operation could complete.

public static final Status.Code
FAILED_PRECONDITION

Operation was rejected because the system is not in a state required for the operation's execution.

public static final Status.Code
INTERNAL

Internal errors.

public static final Status.Code
INVALID_ARGUMENT

Client specified an invalid argument.

public static final Status.Code
NOT_FOUND

Some requested entity (e.g., file or directory) was not found.

public static final Status.Code
OK

The operation completed successfully.

public static final Status.Code
OUT_OF_RANGE

Operation was attempted past the valid range.

public static final Status.Code
PERMISSION_DENIED

The caller does not have permission to execute the specified operation.

public static final Status.Code
RESOURCE_EXHAUSTED

Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.

public static final Status.Code
UNAUTHENTICATED

The request does not have valid authentication credentials for the operation.

public static final Status.Code
UNAVAILABLE

The service is currently unavailable.

public static final Status.Code
UNIMPLEMENTED

Operation is not implemented or not supported/enabled in this service.

public static final Status.Code
UNKNOWN

Unknown error.

private final int
private final byte[]

Constructor Summary

AccessConstructor and Description
private
Code(int value)

Method Summary

Modifier and TypeMethod and Description
public Status
toStatus()

Returns a Status object corresponding to this status code.

public int
value()

The numerical value of the code.

private byte[]
public static Status.Code
public static Status.Code[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ABORTEDback to summary
public static final Status.Code ABORTED

The operation was aborted, typically due to a concurrency issue like sequencer check failures, transaction aborts, etc.

See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE.

ALREADY_EXISTSback to summary
public static final Status.Code ALREADY_EXISTS

Some entity that we attempted to create (e.g., file or directory) already exists.

CANCELLEDback to summary
public static final Status.Code CANCELLED

The operation was cancelled (typically by the caller).

DATA_LOSSback to summary
public static final Status.Code DATA_LOSS

Unrecoverable data loss or corruption.

DEADLINE_EXCEEDEDback to summary
public static final Status.Code DEADLINE_EXCEEDED

Deadline expired before operation could complete. For operations that change the state of the system, this error may be returned even if the operation has completed successfully. For example, a successful response from a server could have been delayed long enough for the deadline to expire.

FAILED_PRECONDITIONback to summary
public static final Status.Code FAILED_PRECONDITION

Operation was rejected because the system is not in a state required for the operation's execution. For example, directory to be deleted may be non-empty, an rmdir operation is applied to a non-directory, etc.

A litmus test that may help a service implementor in deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE: (a) Use UNAVAILABLE if the client can retry just the failing call. (b) Use ABORTED if the client should retry at a higher-level (e.g., restarting a read-modify-write sequence). (c) Use FAILED_PRECONDITION if the client should not retry until the system state has been explicitly fixed. E.g., if an "rmdir" fails because the directory is non-empty, FAILED_PRECONDITION should be returned since the client should not retry unless they have first fixed up the directory by deleting files from it.

INTERNALback to summary
public static final Status.Code INTERNAL

Internal errors. Means some invariants expected by underlying system has been broken. If you see one of these errors, something is very broken.

INVALID_ARGUMENTback to summary
public static final Status.Code INVALID_ARGUMENT

Client specified an invalid argument. Note that this differs from FAILED_PRECONDITION. INVALID_ARGUMENT indicates arguments that are problematic regardless of the state of the system (e.g., a malformed file name).

NOT_FOUNDback to summary
public static final Status.Code NOT_FOUND

Some requested entity (e.g., file or directory) was not found.

OKback to summary
public static final Status.Code OK

The operation completed successfully.

OUT_OF_RANGEback to summary
public static final Status.Code OUT_OF_RANGE

Operation was attempted past the valid range. E.g., seeking or reading past end of file.

Unlike INVALID_ARGUMENT, this error indicates a problem that may be fixed if the system state changes. For example, a 32-bit file system will generate INVALID_ARGUMENT if asked to read at an offset that is not in the range [0,2^32-1], but it will generate OUT_OF_RANGE if asked to read from an offset past the current file size.

There is a fair bit of overlap between FAILED_PRECONDITION and OUT_OF_RANGE. We recommend using OUT_OF_RANGE (the more specific error) when it applies so that callers who are iterating through a space can easily look for an OUT_OF_RANGE error to detect when they are done.

PERMISSION_DENIEDback to summary
public static final Status.Code PERMISSION_DENIED

The caller does not have permission to execute the specified operation. PERMISSION_DENIED must not be used for rejections caused by exhausting some resource (use RESOURCE_EXHAUSTED instead for those errors). PERMISSION_DENIED must not be used if the caller cannot be identified (use UNAUTHENTICATED instead for those errors).

RESOURCE_EXHAUSTEDback to summary
public static final Status.Code RESOURCE_EXHAUSTED

Some resource has been exhausted, perhaps a per-user quota, or perhaps the entire file system is out of space.

UNAUTHENTICATEDback to summary
public static final Status.Code UNAUTHENTICATED

The request does not have valid authentication credentials for the operation.

UNAVAILABLEback to summary
public static final Status.Code UNAVAILABLE

The service is currently unavailable. This is a most likely a transient condition and may be corrected by retrying with a backoff. Note that it is not always safe to retry non-idempotent operations.

See litmus test above for deciding between FAILED_PRECONDITION, ABORTED, and UNAVAILABLE.

UNIMPLEMENTEDback to summary
public static final Status.Code UNIMPLEMENTED

Operation is not implemented or not supported/enabled in this service.

UNKNOWNback to summary
public static final Status.Code UNKNOWN

Unknown error. An example of where this error may be returned is if a Status value received from another address space belongs to an error-space that is not known in this address space. Also errors raised by APIs that do not return enough error information may be converted to this error.

valueback to summary
private final int value
valueAsciiback to summary
private final byte[] valueAscii
Annotations
@SuppressWarnings:ImmutableEnumChecker

Constructor Detail

Codeback to summary
private Code(int value)

Method Detail

toStatusback to summary
public Status toStatus()

Returns a Status object corresponding to this status code.

valueback to summary
public int value()

The numerical value of the code.

valueAsciiback to summary
private byte[] valueAscii()
valueOfback to summary
public static Status.Code valueOf(String name)
valuesback to summary
public static Status.Code[] values()
io.grpc back to summary

private final Class Status.StatusCodeMarshaller

extends Object
implements Metadata.TrustedAsciiMarshaller<Status>
Class Inheritance
All Implemented Interfaces
io.grpc.Metadata.TrustedAsciiMarshaller

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Status
parseAsciiString(byte[]
value of metadata to parse
serialized
)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.parseAsciiString.

Parse a serialized metadata value from an ASCII string.
public byte[]
toAsciiString(Status
to serialize
status
)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.toAsciiString.

Serialize a metadata value to a ASCII string that contains only the characters listed in the class comment of io.grpc.Metadata.AsciiMarshaller.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

StatusCodeMarshallerback to summary
private StatusCodeMarshaller()

Method Detail

parseAsciiStringback to summary
public Status parseAsciiString(byte[] serialized)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.parseAsciiString.

Doc from io.grpc.Metadata.TrustedAsciiMarshaller.parseAsciiString.

Parse a serialized metadata value from an ASCII string.

Parameters
serialized:byte[]

value of metadata to parse

Returns:Status

a parsed instance of type T

Annotations
@Override
toAsciiStringback to summary
public byte[] toAsciiString(Status status)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.toAsciiString.

Doc from io.grpc.Metadata.TrustedAsciiMarshaller.toAsciiString.

Serialize a metadata value to a ASCII string that contains only the characters listed in the class comment of io.grpc.Metadata.AsciiMarshaller. Otherwise the output may be considered invalid and discarded by the transport, or the call may fail.

Parameters
status:Status

to serialize

Returns:byte[]

serialized version of value, or null if value cannot be transmitted.

Annotations
@Override
io.grpc back to summary

private final Class Status.StatusMessageMarshaller

extends Object
implements Metadata.TrustedAsciiMarshaller<String>
Class Inheritance
All Implemented Interfaces
io.grpc.Metadata.TrustedAsciiMarshaller

Field Summary

Modifier and TypeField and Description
private static final byte[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static boolean
public String
parseAsciiString(byte[]
value of metadata to parse
value
)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.parseAsciiString.

Parse a serialized metadata value from an ASCII string.
private static String
parseAsciiStringSlow(byte[] value)

public byte[]
toAsciiString(String
to serialize
value
)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.toAsciiString.

Serialize a metadata value to a ASCII string that contains only the characters listed in the class comment of io.grpc.Metadata.AsciiMarshaller.
private static byte[]
toAsciiStringSlow(byte[]
the UTF-8 bytes
valueBytes
,
int
The reader index, pointed at the first byte that needs escaping.
ri
)

Percent encode bytes to make them ASCII.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

HEXback to summary
private static final byte[] HEX

Constructor Detail

StatusMessageMarshallerback to summary
private StatusMessageMarshaller()

Method Detail

isEscapingCharback to summary
private static boolean isEscapingChar(byte b)
parseAsciiStringback to summary
public String parseAsciiString(byte[] value)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.parseAsciiString.

Doc from io.grpc.Metadata.TrustedAsciiMarshaller.parseAsciiString.

Parse a serialized metadata value from an ASCII string.

Parameters
value:byte[]

value of metadata to parse

Returns:String

a parsed instance of type T

Annotations
@SuppressWarnings:deprecation
@Override
parseAsciiStringSlowback to summary
private static String parseAsciiStringSlow(byte[] value)
toAsciiStringback to summary
public byte[] toAsciiString(String value)

Implements io.grpc.Metadata.TrustedAsciiMarshaller.toAsciiString.

Doc from io.grpc.Metadata.TrustedAsciiMarshaller.toAsciiString.

Serialize a metadata value to a ASCII string that contains only the characters listed in the class comment of io.grpc.Metadata.AsciiMarshaller. Otherwise the output may be considered invalid and discarded by the transport, or the call may fail.

Parameters
value:String

to serialize

Returns:byte[]

serialized version of value, or null if value cannot be transmitted.

Annotations
@Override
toAsciiStringSlowback to summary
private static byte[] toAsciiStringSlow(byte[] valueBytes, int ri)

Percent encode bytes to make them ASCII.

Parameters
valueBytes:byte[]

the UTF-8 bytes

ri:int

The reader index, pointed at the first byte that needs escaping.