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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] - Correctly return the checked out buffer to the pool #2732

Merged
merged 4 commits into from
Apr 23, 2024

Conversation

ahrav
Copy link
Collaborator

@ahrav ahrav commented Apr 23, 2024

Description:

This PR ensures that the BufferedFileWriter returns its underlying buffer to the pool upon being closed after writing.

馃槄
Screenshot 2024-04-23 at 10 17 52鈥疉M

Checklist:

  • Tests passing (make test-community)?
  • Lint passing (make lint this requires golangci-lint)?

@ahrav ahrav requested a review from a team April 23, 2024 17:58
@ahrav ahrav marked this pull request as ready for review April 23, 2024 17:58
@ahrav ahrav requested a review from a team as a code owner April 23, 2024 17:58
@@ -172,6 +172,10 @@ func (w *BufferedFileWriter) CloseForWriting() error {
return nil
}

// Return the buffer to the pool since the contents have been written to the file and
// the writer is transitioning to read-only mode.
w.bufPool.Put(w.buf)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this free up the buffer for use elsewhere? That seems incompatible with reading from it below.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, this was meant to be in a defer. I also clearly missed the failing test which would've also caught this. 馃槗

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

Successfully merging this pull request may close these issues.

None yet

3 participants