- Notifications
You must be signed in to change notification settings - Fork4.6k
Commit83bead4
authored
internal/buffer: set closed flag when closing channel in the Load method (#8575)
## DescriptionThis PR fixes a bug in the `Unbounded.Load()` method where the `closed`flag was not being set to `true` when the channel was closed.## ProblemIn the `Load()` method, when the condition `b.closing && !b.closed` ismet, the code closes the channel but doesn't update the `closed` flag.This creates an inconsistent state where:- The channel is closed (no more data can be sent)- But `b.closed` remains `false`This inconsistency could potentially cause issues in code that relies onthe `closed` flag to determine the buffer's state.## SolutionAdded `b.closed = true` before `close(b.c)` in the `else if` branch ofthe `Load()` method to ensure the closed flag accurately reflects thebuffer's state.## Changes- **File**: `internal/buffer/unbounded.go`- **Method**: `Load()`- **Line**: 86- **Change**: Added `b.closed = true` before closing the channel## Testing- ✅ All existing tests pass- ✅ No linter errors introduced- ✅ The fix ensures consistent state between channel closure and closedflag## ImpactThis is a bug fix that improves the correctness of the `Unbounded`buffer implementation without changing its public API or behavior from auser perspective.Fixes:#8572RELEASE NOTES: None1 parent0f45079 commit83bead4
1 file changed
+1
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
| 86 | + | |
86 | 87 | | |
87 | 88 | | |
88 | 89 | | |
| |||
0 commit comments
Comments
(0)