Skip to content

Commit 83bead4

Browse files
authored
internal/buffer: set closed flag when closing channel in the Load method (#8575)
## Description This PR fixes a bug in the `Unbounded.Load()` method where the `closed` flag was not being set to `true` when the channel was closed. ## Problem In the `Load()` method, when the condition `b.closing && !b.closed` is met, 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 on the `closed` flag to determine the buffer's state. ## Solution Added `b.closed = true` before `close(b.c)` in the `else if` branch of the `Load()` method to ensure the closed flag accurately reflects the buffer'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 closed flag ## Impact This is a bug fix that improves the correctness of the `Unbounded` buffer implementation without changing its public API or behavior from a user perspective. Fixes: #8572 RELEASE NOTES: None
1 parent 0f45079 commit 83bead4

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

internal/buffer/unbounded.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ func (b *Unbounded) Load() {
8383
default:
8484
}
8585
} else if b.closing && !b.closed {
86+
b.closed = true
8687
close(b.c)
8788
}
8889
}

0 commit comments

Comments
 (0)