Skip to content

Commit 7ad80ea

Browse files
orestisflmergify[bot]
authored andcommitted
fbreceiver: close file in writeFile to fix Windows test (#48019)
On Windows, open file handles prevent t.TempDir() cleanup. Add defer f.Close() to properly release the file handle. Fixes test failure introduced in #47969. (cherry picked from commit 061db97)
1 parent 58abf9d commit 7ad80ea

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

x-pack/filebeat/fbreceiver/receiver_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,7 @@ func hostFromSocket(socket string) string {
622622
func writeFile(t require.TestingT, path string, data string) {
623623
f, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644)
624624
require.NoErrorf(t, err, "Could not open file %s", path)
625+
defer f.Close()
625626
_, err = f.WriteString(data + "\n")
626627
require.NoErrorf(t, err, "Could not write %s to file %s", data, path)
627628
}

0 commit comments

Comments
 (0)