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 4 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
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`

## 0.9.0 [2024-08-12]

### Features
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 @@ func (c *ServerlessClient) createBucket(ctx context.Context, path string, bucket
body: bytes.NewReader(body),
}

_, err = c.client.makeAPICall(ctx, param)
return err
resp, err := c.client.makeAPICall(ctx, param)
if err != nil {
return err
}
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
Loading