From b3063ec2b3cf9beab45287fc541995a10a82ebc9 Mon Sep 17 00:00:00 2001 From: Mike Mondragon Date: Fri, 10 Jun 2022 12:46:40 -0700 Subject: [PATCH] Ensure files are getting closed. --- okta/fixtures_test.go | 1 + okta/utils.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/okta/fixtures_test.go b/okta/fixtures_test.go index 4774e9599..e0d09c754 100644 --- a/okta/fixtures_test.go +++ b/okta/fixtures_test.go @@ -32,6 +32,7 @@ func (manager *fixtureManager) GetFixtures(fixtureName string, rInt int, t *test if err != nil { t.Fatalf("failed to load terraform fixtures for ACC test, err: %v", err) } + defer file.Close() rawFile, err := ioutil.ReadAll(file) if err != nil { t.Fatalf("failed to load terraform fixtures for ACC test, err: %v", err) diff --git a/okta/utils.go b/okta/utils.go index fe7a48f56..c24be3c75 100644 --- a/okta/utils.go +++ b/okta/utils.go @@ -415,11 +415,11 @@ func computeFileHash(filename string) string { if err != nil { return "" } + defer file.Close() h := sha256.New() if _, err := io.Copy(h, file); err != nil { log.Fatal(err) } - _ = file.Close() return hex.EncodeToString(h.Sum(nil)) }