Skip to content

ByteBufferOutput.writeAscii does not work for strings of length one #920

Closed
@ulfeks

Description

@ulfeks

Describe the bug
When writing a single ascii character using ByteBufferOutput.writeAscii, reading will fail with an exception.

To Reproduce

public static void main(String[] args) {
        var os = new ByteArrayOutputStream();
        try (ByteBufferOutput out = new ByteBufferOutput(os)) {
            out.writeAscii("A");
            out.flush();
        }

        try (ByteBufferInput input = new ByteBufferInput(os.toByteArray())) {
            System.out.println(input.readString());
        }
    }

Environment:

  • OS: [Windows]
  • JDK Version: [JDK18]
  • Kryo Version: [e.g. 5.3.0]

Additional context
If I replace "A" with "AB" in the sample code above it works just fine. It also works if I use UnsafeInput/UnsafeOutput instead of ByteBufferOutput/ByteBufferInput

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions