Skip to content

awaitContent returns incorrect value when channel is closed with empty buffer #4941

@coderabbitai

Description

@coderabbitai

Description

The awaitContent function in RawSourceChannel incorrectly returns true when the channel is already closed but the buffer is empty. This violates the contract of awaitContent, which should return false when no more data can arrive.

Current Behavior

When closedToken != null, the function immediately returns true regardless of buffer state.

Expected Behavior

When the channel is closed and insufficient data is available in the buffer, awaitContent should return false to indicate that the minimum required data cannot be satisfied.

Impact

This causes callers to attempt reads that immediately hit EOF, as they're misled into thinking sufficient data is available.

Context

This issue was identified during migration PR #4940 but kept unchanged to minimize migration scope. The bug exists in both the original JVM implementation and the new common implementation.

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions