onsi / ginkgo

A Modern Testing Framework for Go
http://onsi.github.io/ginkgo/
MIT License
8.29k stars 654 forks source link

[Bug] File Handler Leak #1308

Closed stasos24 closed 10 months ago

stasos24 commented 10 months ago

In case of error at line: https://github.com/onsi/ginkgo/blob/3b2a2a7e74069d66b0f64922afd3426a6167dd3c/reporters/json_report.go#L23 Handler: https://github.com/onsi/ginkgo/blob/3b2a2a7e74069d66b0f64922afd3426a6167dd3c/reporters/json_report.go#L17 won't be freed on https://github.com/onsi/ginkgo/blob/3b2a2a7e74069d66b0f64922afd3426a6167dd3c/reporters/json_report.go#L27 Solution: Replace - return f.Close() with return 0 Add defer f.Close at line 20

stasos24 commented 10 months ago

In case of error at: https://github.com/onsi/ginkgo/blob/3b2a2a7e74069d66b0f64922afd3426a6167dd3c/reporters/json_report.go#L62 Handler: https://github.com/onsi/ginkgo/blob/3b2a2a7e74069d66b0f64922afd3426a6167dd3c/reporters/json_report.go#L56 won't be freed on: https://github.com/onsi/ginkgo/blob/3b2a2a7e74069d66b0f64922afd3426a6167dd3c/reporters/json_report.go#L64

onsi commented 10 months ago

hey there - thanks for catching for this. can you submit a PR?

stasos24 commented 10 months ago

hey there - thanks for catching for this. can you submit a PR?

Yes, of course https://github.com/onsi/ginkgo/pull/1309