Skip to content

Commit

Permalink
fix(io): file source ignore endLine buffer (#3431) (#3433)
Browse files Browse the repository at this point in the history
Signed-off-by: Jiyong Huang <huangjy@emqx.io>
  • Loading branch information
ngjaying authored Dec 9, 2024
1 parent dddcd8d commit 85af151
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions internal/io/file/source.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package file

import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -325,7 +326,7 @@ func ignoreLines(ctx api.StreamContext, reader io.Reader, decorator modules.File
if ignoreEndLines > 0 { // the last n line are left in the tempLines
slot := (ln - ignoreStartLines) % ignoreEndLines
if len(tempLines) <= slot { // first round
tempLines = append(tempLines, scanner.Bytes())
tempLines = append(tempLines, bytes.Clone(scanner.Bytes()))
} else {
_, err := w.Write(tempLines[slot])
if err != nil {
Expand All @@ -337,7 +338,7 @@ func ignoreLines(ctx api.StreamContext, reader io.Reader, decorator modules.File
ctx.GetLogger().Error(err)
break
}
tempLines[slot] = scanner.Bytes()
tempLines[slot] = bytes.Clone(scanner.Bytes())
}
} else {
_, err := w.Write(scanner.Bytes())
Expand Down

0 comments on commit 85af151

Please sign in to comment.