diff --git a/internal/impl/io/input_file.go b/internal/impl/io/input_file.go index ba43afdcbc..e261555f75 100644 --- a/internal/impl/io/input_file.go +++ b/internal/impl/io/input_file.go @@ -197,8 +197,10 @@ func (f *fileConsumer) ReadBatch(ctx context.Context) (service.MessageBatch, ser err = component.ErrTimeout } if err != component.ErrTimeout { + f.scannerMut.Lock() scannerInfo.scanner.Close(ctx) f.scannerInfo = nil + f.scannerMut.Unlock() } if errors.Is(err, io.EOF) { continue