Skip to content
This repository has been archived by the owner on May 25, 2022. It is now read-only.

Commit

Permalink
Only complain about file closing if error is unexpected
Browse files Browse the repository at this point in the history
  • Loading branch information
djaglowski committed Jun 9, 2021
1 parent aca340a commit 95db127
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion operator/builtin/input/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"fmt"
"os"
"path/filepath"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -153,7 +154,11 @@ func (f *InputOperator) poll(ctx context.Context) {

// Close all files
for _, reader := range readers {
reader.Close() // #nosec - don't complain if the file is already closed
if err := reader.Close(); err != nil {
if !strings.HasSuffix(err.Error(), "file already closed") {
f.Errorf("problem closing reader", "file", reader.file.Name())
}
}
}

f.saveCurrent(readers)
Expand Down

0 comments on commit 95db127

Please sign in to comment.