Skip to content

close response on retry#409

Merged
domesticmouse merged 1 commit intogooglemaps:masterfrom
esetnik:close_response_retry
Mar 22, 2018
Merged

close response on retry#409
domesticmouse merged 1 commit intogooglemaps:masterfrom
esetnik:close_response_retry

Conversation

@esetnik
Copy link
Copy Markdown
Contributor

@esetnik esetnik commented Mar 22, 2018

This fixes the issue reported in #179

@googlebot
Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers
  • Your company has a Point of Contact who decides which employees are authorized to participate. Ask your POC to be added to the group of authorized contributors. If you don't know who your Point of Contact is, direct the project maintainer to go/cla#troubleshoot.
  • The email used to register you as an authorized contributor must be the email used for the Git commit. Check your existing CLA data and verify that your email is set on your git commits.
  • The email used to register you as an authorized contributor must also be attached to your GitHub account.

@esetnik
Copy link
Copy Markdown
Contributor Author

esetnik commented Mar 22, 2018

I signed it!

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

@esetnik
Copy link
Copy Markdown
Contributor Author

esetnik commented Mar 22, 2018

I've been running the alternative version in our production codebase for the last two weeks without a recurrence of #179

According to the ResponseBody documentation

For synchronous calls, the easiest way to make sure a response body is closed is with a try block. With this structure the compiler inserts an implicit finally clause that calls close() for you.

   

   Call call = client.newCall(request);
   try (Response response = call.execute()) {
     ... // Use the response.
   }

Which is closed on https://github.com/googlemaps/google-maps-services-java/blob/master/src/main/java/com/google/maps/internal/OkHttpPendingResult.java#L225. But if the code short circuits due to shouldRetry(response) returning true, then the response is never closed.

@domesticmouse
Copy link
Copy Markdown
Contributor

Good catch, thanks!

@domesticmouse domesticmouse merged commit 7f07a21 into googlemaps:master Mar 22, 2018
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