Skip to content

UTF8JsonGenerator.writeBinary() should allocate buffer based on supplied length #1622

Description

@kilink

Currently UTF8JsonGenerator#writeBinary does not pass the size hint to allocBase64Buffer:

byte[] encodingBuffer = _ioContext.allocBase64Buffer();

Any reason it couldn't? I am writing binary from a protobuf InputStream, and if the byte[] array passed to its read method is smaller than the proto's serialized size, it triggers serialization to an in memory byte array first before filling the passed in buffer. I'm trying to think of a reason why we can't use the supplied size to allocate the encode buffer? It seems the default is 2000 bytes which is pretty small.

Metadata

Metadata

Assignees

No one assigned

    Labels

    pr-neededFeature request for which PR likely needed (no active development but idea is workable)

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions