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

StrictMode warning about an unclosed resourse #474

Closed
RobertoArtiles opened this issue May 27, 2015 · 7 comments
Closed

StrictMode warning about an unclosed resourse #474

RobertoArtiles opened this issue May 27, 2015 · 7 comments
Labels

Comments

@RobertoArtiles
Copy link

[extracted from https://github.com//pull/61]

Getting a StrictMode warning on the latest Glide 3.6.0 .(see square/okhttp#1053)

05-27 15:43:35.058    7180-7192/com.witdot.twinkie E/StrictMode﹕ A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    java.lang.Throwable: Explicit termination method 'close' not called
            at dalvik.system.CloseGuard.open(CloseGuard.java:184)
            at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:287)
            at com.squareup.okhttp.Connection.upgradeToTls(Connection.java:242)
            at com.squareup.okhttp.Connection.connect(Connection.java:159)
            at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:175)
            at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120)
            at com.squareup.okhttp.internal.http.HttpEngine.nextConnection(HttpEngine.java:330)
            at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:319)
            at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:241)
            at com.squareup.okhttp.Call.getResponse(Call.java:271)
            at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:228)
            at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:199)
            at com.squareup.okhttp.Call.execute(Call.java:79)
            at com.bumptech.glide.integration.okhttp.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:48)
            at com.bumptech.glide.integration.okhttp.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:19)
            at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:70)
            at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:53)
            at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:170)
            at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128)
            at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122)
            at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101)
            at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:818)
            at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)
``
@sjudd
Copy link
Collaborator

sjudd commented May 27, 2015

By your reference, it looks like you're using the OkHttp integration library?

@RobertoArtiles
Copy link
Author

Correct. okhttp-urlconnection 2.3.0

@sjudd
Copy link
Collaborator

sjudd commented May 28, 2015

Unlike the referenced OkHttp issue, as far as I can tell, we do in fact call close on the response body. Close is called in cleanup here: https://github.com/bumptech/glide/blob/3.0/integration/okhttp/src/main/java/com/bumptech/glide/integration/okhttp/OkHttpStreamFetcher.java#L60

And cleanup is called in a finally block here: https://github.com/bumptech/glide/blob/3.0/library/src/main/java/com/bumptech/glide/load/engine/DecodeJob.java#L179

You can also see that cleanup is delegated in the wrapping ImageVideoModelLoader here:
https://github.com/bumptech/glide/blob/3.0/library/src/main/java/com/bumptech/glide/load/model/ImageVideoModelLoader.java#L100

If you can reproduce this reliably, do you maybe want to put in a break point and verify whether or not the response body is in fact being closed?

Also do you still see the same exception if you use OkHttp 2.2.0 (the version Glide's integration library is compiled against, see: https://github.com/bumptech/glide/blob/3.0/gradle.properties#L21)?

@sjudd
Copy link
Collaborator

sjudd commented Jun 17, 2015

Let me know if you get the chance to try anything I mentioned in my last comment.

@sjudd sjudd closed this as completed Jun 17, 2015
@seroperson
Copy link

Same exception with 2.2.0 and 2.4.0

A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
    java.lang.Throwable: Explicit termination method 'close' not called
            at dalvik.system.CloseGuard.open(CloseGuard.java:184)
            at com.android.org.conscrypt.OpenSSLSocketImpl.startHandshake(OpenSSLSocketImpl.java:278)
            at com.squareup.okhttp.Connection.upgradeToTls(Connection.java:241)
            at com.squareup.okhttp.Connection.connect(Connection.java:158)
            at com.squareup.okhttp.Connection.connectAndSetOwner(Connection.java:174)
            at com.squareup.okhttp.OkHttpClient$1.connectAndSetOwner(OkHttpClient.java:120)
            at com.squareup.okhttp.internal.http.RouteSelector.next(RouteSelector.java:131)
            at com.squareup.okhttp.internal.http.HttpEngine.connect(HttpEngine.java:312)
            at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:235)
            at com.squareup.okhttp.Call.getResponse(Call.java:262)
            at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:219)
            at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:192)
            at com.squareup.okhttp.Call.execute(Call.java:79)
            at com.bumptech.glide.integration.okhttp.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:42)
            at com.bumptech.glide.integration.okhttp.OkHttpStreamFetcher.loadData(OkHttpStreamFetcher.java:19)
            at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:70)
            at com.bumptech.glide.load.model.ImageVideoModelLoader$ImageVideoFetcher.loadData(ImageVideoModelLoader.java:53)
            at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:170)
            at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:128)
            at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:122)
            at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:101)
            at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:58)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
            at java.util.concurrent.FutureTask.run(FutureTask.java:237)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
            at java.lang.Thread.run(Thread.java:841)
            at com.bumptech.glide.load.engine.executor.FifoPriorityThreadPoolExecutor$DefaultThreadFactory$1.run(FifoPriorityThreadPoolExecutor.java:118)

@TWiStErRob
Copy link
Collaborator

@seroperson there was no code change, the original OP didn't help out other than stating there's an issue. Without proper repoduction steps it's hard to fix it, see #474 (comment) where Sam shows in code where the actual closes happen and asks do debug whether those are correctly called. Please investigate more if you can and report back on those points.

@seroperson
Copy link

I can't reproduce it because it throws randomly. Maybe I will add some details later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants