Skip to content

Close ResponseBody #195

Description

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 (@link) Response#body} method. To facilitate connection recycling, callers
  • should always {Link (@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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:defectBugs or weaknesses. The issue has to contain steps to reproduce.

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions