Skip to content

Commit

Permalink
prefer defer resp.Body.Close to avoid leaks on subsequent errors
Browse files Browse the repository at this point in the history
  • Loading branch information
coryb committed May 25, 2019
1 parent f6809e3 commit 181bd74
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion search.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ func Search(ua HttpClient, endpoint string, sp SearchProvider) (*jiradata.Search
if err != nil {
return nil, err
}
defer resp.Body.Close()

if resp.StatusCode != 200 {
return nil, responseError(resp)
Expand All @@ -107,7 +108,6 @@ func Search(ua HttpClient, endpoint string, sp SearchProvider) (*jiradata.Search
if len(issues) == results.Total || results.Total == 0 {
break
}
resp.Body.Close()
}
results.Issues = issues
return results, nil
Expand Down

0 comments on commit 181bd74

Please sign in to comment.