Skip to content

Connection leak due to not closing input stream on error #179

@ben-manes

Description

@ben-manes

WARN [2016-09-14 22:31:24,510] com.squareup.okhttp.OkHttpClient: A connection to https://maps.googleapis.com/ was leaked. Did you forget to close a response body?

OkHttpPendingResult#getBytes() does not close input stream. While OkHttp can recover on a 2xx, it will not do this for you on an error code. As explained, they expect callers to write proper resource management code.

When a failure occurs this library typically hangs, as seen in #161, and requires callers perform their own timeouts. Unfortunately calling PendingResult#cancel() afterwards is not good enough to recover, because the connection is stuck by the open input stream. Eventually the pool will be exhausted and no new requests are performed. The only resolution is to restart the application.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions