Skip to content

Commit

Permalink
[Filebeat] keep track of bytes read when max_bytes exceeded in the la…
Browse files Browse the repository at this point in the history
…st line (#31882)
  • Loading branch information
liuwenping authored and chrisberkhout committed Jun 1, 2023
1 parent 753154e commit d530148
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libbeat/reader/readfile/line.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,10 @@ func (r *LineReader) Next() (b []byte, n int, err error) {
// read next 'potential' line from input buffer/reader
err := r.advance()
if err != nil {
return nil, 0, err
// return and reset consumed bytes count
sz := r.byteCount
r.byteCount = 0
return nil, sz, err
}

// Check last decoded byte really being newline also unencoded
Expand Down
1 change: 1 addition & 0 deletions libbeat/reader/readfile/line_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ func TestMaxBytesLimit(t *testing.T) {
b, n, err := reader.Next()
if err != nil {
if err == io.EOF {
readLen += n
break
} else {
t.Fatal("unexpected error:", err)
Expand Down

0 comments on commit d530148

Please sign in to comment.