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: close response body in mapping functions #140

Merged
merged 5 commits into from
Dec 22, 2024

Conversation

Mohammad-Dwairi
Copy link
Contributor

Situation

We've noticed that HTTP responses are not closed properly in some places where we do the Request/Response mappings for OkHttp and Apollo Clients.

Task

Ensure that original responses coming from OkHttp and ApolloClient are closed properly after mapping from/to SDK HTTP models.

Action

  1. Called the use() function in all response body mapping functions. use() ensures that the consumed resource is closed by calling close() function automatically.
  2. Since we're closing the responses after mapping, we needed to copy the buffer from the original response in order to be able to consume it.
  3. Added unit test to validate the changes.

Testing

All existing and new tests are passing ✅

@Mohammad-Dwairi Mohammad-Dwairi requested a review from a team as a code owner December 22, 2024 12:57
@Mohammad-Dwairi Mohammad-Dwairi merged commit 334b8d3 into main Dec 22, 2024
1 check passed
@Mohammad-Dwairi Mohammad-Dwairi deleted the mdwairi/close-response-body-resources branch December 22, 2024 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants