Skip to content
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: unclosed body causing resource leak #94

Merged
merged 9 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ workflows:
build:
jobs:
- tests-go
- lint
- lint
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ output:

# Show statistics per linter.
# Default: false
show-stats: true
show-stats: true
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## 0.10.0 [unreleased]

### Bug Fixes

1. [#94](https://github.com/InfluxCommunity/influxdb3-go/pull/94): Resource leak from unclosed `Response`

### CI

1. [#95](https://github.com/InfluxCommunity/influxdb3-go/pull/95): Add `golangci-lint` to CI
Expand Down
7 changes: 5 additions & 2 deletions influxdb3/management_cloud_decicated.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,9 @@ func (d *CloudDedicatedClient) createDatabase(ctx context.Context, path string,
body: bytes.NewReader(body),
}

_, err = d.client.makeAPICall(ctx, param)
return err
resp, err := d.client.makeAPICall(ctx, param)
if err != nil {
return err
}
return resp.Body.Close()
}
7 changes: 5 additions & 2 deletions influxdb3/management_serverless.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@
body: bytes.NewReader(body),
}

_, err = c.client.makeAPICall(ctx, param)
return err
resp, err := c.client.makeAPICall(ctx, param)
if err != nil {
return err
}

Check warning on line 101 in influxdb3/management_serverless.go

View check run for this annotation

Codecov / codecov/patch

influxdb3/management_serverless.go#L100-L101

Added lines #L100 - L101 were not covered by tests
return resp.Body.Close()
}
7 changes: 5 additions & 2 deletions influxdb3/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,17 @@ func (c *Client) write(ctx context.Context, buff []byte, options *WriteOptions)
}
headers["Content-Encoding"] = []string{"gzip"}
}
_, err = c.makeAPICall(ctx, httpParams{
resp, err := c.makeAPICall(ctx, httpParams{
endpointURL: u,
httpMethod: "POST",
headers: headers,
queryParams: u.Query(),
body: body,
})
return err
if err != nil {
return err
}
return resp.Body.Close()
}

// WriteData encodes fields of custom points into line protocol
Expand Down