-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: response body after HTTP error should be closed #106
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #106 +/- ##
==========================================
+ Coverage 85.32% 85.35% +0.03%
==========================================
Files 14 14
Lines 1124 1127 +3
==========================================
+ Hits 959 962 +3
Misses 137 137
Partials 28 28
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
CHANGELOG.md
Outdated
### Features | ||
|
||
1. [#105](https://github.com/InfluxCommunity/influxdb3-go/pull/105): Support newlines in tag values. | ||
|
||
### Bug Fixes | ||
|
||
1. [#106](https://github.com/InfluxCommunity/influxdb3-go/pull/106): Close `resp.Body` after HTTP error response is encountered. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Both should be Bug Fixes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated
influxdb3/client.go
Outdated
closingErr := resp.Body.Close() | ||
if closingErr != nil { | ||
slog.Warn(fmt.Sprintf("Failed to close response body on HTTP Error(%s): %s", | ||
err.Error(), | ||
closingErr.Error())) | ||
} else { | ||
slog.Debug(fmt.Sprintf("Closed response body on HTTP Error(%s)", err.Error())) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move closing of the response body to the resolveHTTPError
method and omit useless logging. As it is in the InfluxDB Go Client v2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved, and corresponding tests have been removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Closes #102
Proposed Changes
client.resolveHttpError
returns an error, ensure thatresp.Body.Close()
gets called. Otherwise resources may be leaked.Checklist