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

Logs show a lot of connexions leaked #43

Open
3c71 opened this issue Mar 21, 2020 · 0 comments
Open

Logs show a lot of connexions leaked #43

3c71 opened this issue Mar 21, 2020 · 0 comments

Comments

@3c71
Copy link
Contributor

3c71 commented Mar 21, 2020

It seems response bodies are never closed and I get many of those similar logs:

A connection to xxxxxxxxx was leaked. Did you forget to close a response body?
2020-03-21 12:39:07.457 28144-29092/xxxx W/OkHttp: java.lang.Throwable: response.body().close()
2020-03-21 12:39:07.457 28144-29092/xxxx W/OkHttp: at okhttp3.internal.platform.Platform.getStackTraceForCloseable(Platform.kt:134)
2020-03-21 12:39:07.457 28144-29092/xxxx W/OkHttp: at okhttp3.internal.connection.RealCall.callStart(RealCall.kt:166)
2020-03-21 12:39:07.457 28144-29092/xxxx W/OkHttp: at okhttp3.internal.connection.RealCall.execute(RealCall.kt:145)

I've started fixing those, and will post a PR if I get time to test.

However I have a question for you, which one would be best:

response.body().close(); // <-- This leads to a warning that body() might be null.
or
response.close(); // <-- This does an assert that'll throw an exception if body() is null.

I'd rather change the last close() to be safe no matter what. We don't want a crash or an exception if the query has been processed and something goes wrong after, do we? I don't and rather see things go smooth without having to manage exceptions everywhere (or the bare minimum), IMHO.

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

No branches or pull requests

1 participant