Skip to content

Overloads for flattened ByteString method args #3590

@bdhess

Description

@bdhess

It would be nice if flattened RPC calls had overloads that accepted standard Java types (i.e. a Java byte[] and/or ByteBuffer) instead of always requiring a protobuf ByteString. The latter ends up leaking an implementation detail to callers.

As an example, in Cloud KMS we currently have:

String textRaw = "The quick brown fox jumps over the lazy dog!";
byte[] textBytes = textRaw.getBytes(StandardCharsets.UTF_8);
EncryptResponse encryptResp = client.encrypt(keyPath, ByteString.copyFrom(textBytes));

It would be nice if the final line could be

EncryptResponse encryptResp = client.encrypt(keyPath, textBytes);

or

EncryptResponse encryptResp = client.encrypt(keyPath, ByteBuffer.wrap(textBytes));

Metadata

Metadata

Assignees

Labels

priority: p2Moderately-important priority. Fix may not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions