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

Close ResponseBody #195

Closed
sowieso-fruehling opened this issue Feb 28, 2018 · 2 comments
Closed

Close ResponseBody #195

sowieso-fruehling opened this issue Feb 28, 2018 · 2 comments
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.

Comments

@sowieso-fruehling
Copy link
Contributor

I'm using your snowplow-java-tracker:0.8.2 and I have a following issue occuring:

WARN [OkHttp ConnectionPool][][] c.s.o.OkHttpClient 305: A connection to <my_url> was leaked. Did you forget to close a response body?

After debugging it I saw that your code is calling AbstractHttpClientAdapter.post(SelfDescribingJson payload) which calls OkHttpClientAdapter.doPost(String url, String payload) which calls com.squareup.okhttp.Call.execute() and documentation for this method says:

The caller may read the response body with the response's

  • {@link Response#body} method. To facilitate connection recycling, callers
  • should always {@link ResponseBody#close() close the response body}.

and you're not doing it in your library. OkHttpClientAdapter.doPost(String url, String payload) returns response code and never closes response body. Reading other resources it seems that the warning I get is exactly the consequence of not closing it

Did I get something wrong here, or it's a bug?

@BenFradet
Copy link
Contributor

It does look like an oversight, feel free to open a pull request 👍

@alexanderdean alexanderdean added the type:defect Bugs or weaknesses. The issue has to contain steps to reproduce. label Feb 28, 2018
sowieso-fruehling pushed a commit to sowieso-fruehling/snowplow-java-tracker that referenced this issue Feb 28, 2018
@sowieso-fruehling
Copy link
Contributor Author

I made a pull request but not all of your CI jobs are passing. java 8 one passes but java 7 ones are failing, and it's not related to my changes

@BenFradet BenFradet changed the title leaked connection Close ResponseBody Mar 5, 2018
mhadam pushed a commit that referenced this issue Jan 2, 2019
mhadam pushed a commit that referenced this issue Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:defect Bugs or weaknesses. The issue has to contain steps to reproduce.
Projects
None yet
Development

No branches or pull requests

3 participants