Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ulfeks opened this issue Oct 4, 2022 · 2 comments · Fixed by #921
Closed

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

ulfeks opened this issue Oct 4, 2022 · 2 comments · Fixed by #921
Assignees
Labels

Comments

@ulfeks
Copy link

ulfeks commented Oct 4, 2022

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

@theigl
Copy link
Collaborator

theigl commented Oct 5, 2022

Thanks for the report. This is now fixed on master. Please verify against the latest snapshot build.

@ulfeks
Copy link
Author

ulfeks commented Oct 5, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants