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

Never flush without items #1

Merged
merged 2 commits into from
Nov 21, 2024
Merged

Never flush without items #1

merged 2 commits into from
Nov 21, 2024

Conversation

gzuidhof
Copy link
Contributor

In a shutdown situation it was possible flush was called with an empty items slice - this prevents that and adds a test case for it.

This would happen when:

  • The context has been cancelled
  • The buffer is empty
  • The current items array is empty.

skipFlush would be false:

isCancelled && len(b.buffer) > 0 && !maxSize

the len(b.buffer) > 0 would be false, but there was no check whether there are any entries to be flushed.

@gzuidhof gzuidhof requested a review from mikemherron November 21, 2024 10:39
@gzuidhof gzuidhof self-assigned this Nov 21, 2024
Copy link

@mikemherron mikemherron left a comment

Choose a reason for hiding this comment

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

👍

@gzuidhof gzuidhof merged commit bc0c89b into main Nov 21, 2024
4 checks passed
@gzuidhof gzuidhof deleted the no-flush-empty-in-shutdown branch November 21, 2024 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants