Skip to content

Commit 061fd26

Browse files
Enable reading from a closed gbytes.Buffer (#575)
1 parent 758e947 commit 061fd26

File tree

2 files changed

+0
-19
lines changed

2 files changed

+0
-19
lines changed

gbytes/buffer.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,11 @@ func (b *Buffer) Write(p []byte) (n int, err error) {
8787
/*
8888
Read implements the io.Reader interface. It advances the
8989
cursor as it reads.
90-
91-
Returns an error if called after Close.
9290
*/
9391
func (b *Buffer) Read(d []byte) (int, error) {
9492
b.lock.Lock()
9593
defer b.lock.Unlock()
9694

97-
if b.closed {
98-
return 0, errors.New("attempt to read from closed buffer")
99-
}
100-
10195
if uint64(len(b.contents)) <= b.readCursor {
10296
return 0, io.EOF
10397
}

gbytes/buffer_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,6 @@ var _ = Describe("Buffer", func() {
105105
Expect(err).Should(Equal(io.EOF))
106106
Expect(n).Should(Equal(0))
107107
})
108-
109-
Context("after the buffer has been closed", func() {
110-
It("returns an error", func() {
111-
buffer := BufferWithBytes([]byte("abcde"))
112-
113-
buffer.Close()
114-
115-
dest := make([]byte, 3)
116-
n, err := buffer.Read(dest)
117-
Expect(err).Should(HaveOccurred())
118-
Expect(n).Should(Equal(0))
119-
})
120-
})
121108
})
122109

123110
Describe("detecting regular expressions", func() {

0 commit comments

Comments
 (0)