question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected connection leak message in 3.0.0-RC1

See original GitHub issue

I’m using the published 3.0.0-RC1.

I’m seeing this message:

WARNING: A connection to https://api.push.apple.com/ was leaked. Did you forget to close a response body?
Jan 08, 2016 8:23:58 PM okhttp3.ConnectionPool pruneAndGetAllocationCount

Over and over.

My code looks like this:

    client.newCall(request).enqueue(new Callback() {
      override def onFailure(request: Request, throwable: IOException) {
      }

      override def onResponse(response: Response) {
        if (!response.isSuccessful()) {
          val body = response.body()
          val charStream = body.charStream()
          val reason = GSON.fromJson(charStream, classOf[APNSError])
          body.close()
        }
      }
    })

(Note that the example Gson recipe leaks the body there, but this doesn’t.)

Do I need to close the body in the successful case even if I’m not reading it?

Thanks!

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
omarkilanicommented, Jan 8, 2016

Alright – I think the docs could be clearer here. 😃

None of these https://github.com/square/okhttp/wiki/Recipes call close.

0reactions
JakeWhartoncommented, Jun 10, 2017

Retrofit closes it for you

On Sat, Jun 10, 2017 at 6:55 PM Etienne Lawlor notifications@github.com wrote:

Instead of having a Retrofit Service interface which returns Call mine returns Observable. I am using RxJava and calling observable.subscribe(). Where would be the correct place to close the response body?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/square/okhttp/issues/2217#issuecomment-307594888, or mute the thread https://github.com/notifications/unsubscribe-auth/AAEEEXT3pTH-9ea7ogjuw49MliPNbiYCks5sCx7FgaJpZM4HBcqs .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Release Notes for Zabbix 3.0.0rc1
This document contains the release notes for Zabbix 3.0.0rc1. ... ZBX-9895, Fixed memory leak in case of unsupported field type while ...
Read more >
Apparent connection leak detected with Hikari CP
You're using a recent version of Hikari CP and the connection leak resolves by itself (as visible in your logs). As noted by...
Read more >
3.x Change Log - OkHttp
Fix: Provide actionable advice when the exchange is non-null. Prior to 3.14, OkHttp would silently leak connections when an interceptor retries without closing ......
Read more >
Apache Log4j Security Vulnerabilities
Apache Log4j Security Vulnerabilities. This page lists all the security vulnerabilities fixed in released versions of Apache Log4j 2.
Read more >
uamqp · PyPI
Fixed memory leak in win32 socketio and tlsio (azure-sdk-for-python issue #19777). ... Added support for AMQP Sequence as the body type of an...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found