Skip to content

Don't drop bytes from the buffered reader when reading short#2646

Merged
glbrntt merged 1 commit intoapple:mainfrom
glbrntt:read-short
Feb 13, 2024
Merged

Don't drop bytes from the buffered reader when reading short#2646
glbrntt merged 1 commit intoapple:mainfrom
glbrntt:read-short

Conversation

@glbrntt
Copy link
Copy Markdown
Contributor

@glbrntt glbrntt commented Feb 12, 2024

Motivation:

When the BufferedReader reads short when filling its buffer during a request for some bytes, it may avoid giving the caller all bytes available. The bytes remain in the buffer and are available on the next call but this appears to the caller as if the file has been read completely as the returned bytes are less than those requested.

Modifications:

  • Read the expected bytes or whatever is left in the buffer
  • Add a test

Result:

Less unexpected behaviour

Motivation:

When the `BufferedReader` reads short when filling its buffer during a
request for some bytes, it may avoid giving the caller all bytes
available. The bytes remain in the buffer and are available on the next
call but this appears to the caller as if the file has been read
completely as the returned bytes are less than those requested.

Modifications:

- Read the expected bytes or whatever is left in the buffer
- Add a test

Result:

Less unexpected behaviour
@glbrntt glbrntt added the 🔨 semver/patch No public API change. label Feb 12, 2024
@glbrntt glbrntt requested a review from FranzBusch February 12, 2024 18:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants