In conjunction with Picasso [2.3.2] I received the following exception, probably caused by okhttp 2.0.0:
09-09 16:34:33.158 15203-15212/cc.closeup.android 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 java.io.FileInputStream.
at com.squareup.okhttp.internal.DiskLruCache.get(DiskLruCache.java:417)
at com.squareup.okhttp.Cache.get(Cache.java:158)
at com.squareup.okhttp.Cache$1.get(Cache.java:117)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:221)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:420)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:371)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:466)
at com.squareup.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:105)
at com.squareup.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:25)
at com.squareup.picasso.OkHttpDownloader.load(OkHttpDownloader.java:105)
at com.squareup.picasso.NetworkBitmapHunter.decode(NetworkBitmapHunter.java:46)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:144)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:101)
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.squareup.picasso.Utils$PicassoThread.run(Utils.java:394)
I haven't had time to investigate the issue further, but it looks to me as if okhttp/Picasso did not explicitly close a cache handle.
I am tracking at https://github.com/square/picasso/issues/296. Closing this to avoid duplication. Will re-open if it's determined to be an OkHttp issue.
I got the same problem when I use castcompanionlibrary, So this problem might on okhttp side.
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 java.io.FileInputStream.
at com.android.okhttp.internal.DiskLruCache.get(DiskLruCache.java:418)
at com.android.okhttp.HttpResponseCache.get(HttpResponseCache.java:207)
at com.android.okhttp.HttpResponseCache$1.get(HttpResponseCache.java:149)
at com.android.okhttp.internal.http.HttpEngine.initResponseSource(HttpEngine.java:224)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:185)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:345)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)
at com.google.sample.castcompanionlibrary.utils.FetchBitmapTask.doInBackground(FetchBitmapTask.java:78)
at com.google.sample.castcompanionlibrary.utils.FetchBitmapTask.doInBackground(FetchBitmapTask.java:38)
at android.os.AsyncTask$2.call(AsyncTask.java:288)
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)
Here's another one using okhttp + retrofit
Versions
compile 'com.squareup.retrofit:retrofit:1.8.0'
compile 'com.squareup.okhttp:okhttp:2.1.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.1.0'
Stacktrace
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 java.io.FileInputStream.<init>(FileInputStream.java:78)
at okio.Okio.source(Okio.java:160)
at com.squareup.okhttp.internal.DiskLruCache.get(DiskLruCache.java:422)
at com.squareup.okhttp.Cache.get(Cache.java:153)
at com.squareup.okhttp.Cache$1.get(Cache.java:112)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:217)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:423)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:374)
at com.squareup.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:469)
at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:73)
at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:321)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:278)
at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at retrofit.Platform$Android$2$1.run(Platform.java:142)
at java.lang.Thread.run(Thread.java:818)
´´´
I have the same issue. It'd be killer if you guys could fix this... or tell me what I'm doing wrong.
Versions:
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.2.0'
compile 'com.squareup.okhttp:okhttp:2.2.0'
Stack trace
05-20 15:34:52.574 15295-15305/com.xvia.debug.android 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 java.io.FileInputStream.<init>(FileInputStream.java:78)
at okio.Okio.source(Okio.java:160)
at com.squareup.okhttp.internal.DiskLruCache$Entry.snapshot(DiskLruCache.java:1038)
at com.squareup.okhttp.internal.DiskLruCache.get(DiskLruCache.java:418)
at com.squareup.okhttp.Cache.get(Cache.java:155)
at com.squareup.okhttp.Cache$1.get(Cache.java:114)
at com.squareup.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:216)
at com.squareup.okhttp.Call.getResponse(Call.java:262)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:219)
at com.bob.android.core.network.request.OfflineInterceptor.intercept(OfflineInterceptor.java:42)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:216)
at com.bob.android.core.network.request.VersionInterceptor.intercept(VersionInterceptor.java:34)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:216)
at com.bob.android.core.network.request.AuthorizationInterceptor.intercept(AuthorizationInterceptor.java:55)
at com.squareup.okhttp.Call$ApplicationInterceptorChain.proceed(Call.java:216)
at com.squareup.okhttp.Call.getResponseWithInterceptorChain(Call.java:192)
at com.squareup.okhttp.Call.execute(Call.java:79)
at retrofit.client.OkClient.execute(OkClient.java:53)
at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:326)
at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:220)
at retrofit.RestAdapter$RestHandler$1.invoke(RestAdapter.java:265)
at retrofit.RxSupport$2.run(RxSupport.java:55)
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)
@jetherton it's likely a problem with how you're converting the OkHttp response body into a Retrofit response object. Your adapter must close the stream.
@swankjesse Isn't that something that Retrofit should take care of?
Edit: Looks like the issue has been found and solved in the next verison of retrofit: https://github.com/square/retrofit/issues/801
im also experiencing this problem and im not using retrofit. it's after using gzipinputstream. cant' figure out why samsung q.a. gives out this error in their devices whereas i try it in my device and it is ok
i am only using 'com.squareup.okhttp:okhttp:2.4.0'
I have the same problem, using 'com.squareup.okhttp:okhttp:2.6.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:180)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at com.android.okhttp.okio.Okio.source(Okio.java:159)
at com.android.okhttp.internal.io.FileSystem$1.source(FileSystem.java:44)
at com.android.okhttp.internal.DiskLruCache$Entry.snapshot(DiskLruCache.java:1002)
at com.android.okhttp.internal.DiskLruCache.get(DiskLruCache.java:430)
at com.android.okhttp.Cache.get(Cache.java:180)
at com.android.okhttp.Cache$1.get(Cache.java:139)
at com.android.okhttp.internal.http.HttpEngine.sendRequest(HttpEngine.java:229)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:433)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:384)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:497)
at com.squareup.picasso.UrlConnectionDownloader.load(UrlConnectionDownloader.java:93)
at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:47)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:216)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:169)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:423)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:422)
I have the same problem,I have the same problem, using 'com.squareup.okhttp3:okhttp:3.2.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 java.io.FileInputStream.<init>(FileInputStream.java:78)
at okio.Okio.source(Okio.java:168)
at okhttp3.internal.io.FileSystem$1.source(FileSystem.java:44)
at okhttp3.internal.DiskLruCache$Entry.snapshot(DiskLruCache.java:1040)
at okhttp3.internal.DiskLruCache.get(DiskLruCache.java:436)
at okhttp3.Cache.get(Cache.java:193)
at okhttp3.Cache$1.get(Cache.java:143)
at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:203)
at okhttp3.RealCall.getResponse(RealCall.java:243)
at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201)
at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163)
at okhttp3.RealCall.access$100(RealCall.java:30)
at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127)
at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
I see the same issue, more than 1.5 years later.
Using OkHttp 3.9.1 and Picasso 2.5.2.
My StrictMode VmPolicy has detectAll(), and my Picasso invocation from RecyclerView is just:
Picasso.with(context).load(url).placeholder(resId).into(imageView);
The stack trace:
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:180)
at java.io.FileOutputStream.<init>(FileOutputStream.java:222)
at java.io.FileOutputStream.<init>(FileOutputStream.java:169)
at com.android.okhttp.okio.Okio.sink(Okio.java:179)
at com.android.okhttp.internal.io.FileSystem$1.sink(FileSystem.java:49)
at com.android.okhttp.internal.DiskLruCache$Editor.newSink(DiskLruCache.java:875)
at com.android.okhttp.Cache$CacheRequestImpl.<init>(Cache.java:431)
at com.android.okhttp.Cache.put(Cache.java:240)
at com.android.okhttp.Cache.-wrap0(Cache.java)
at com.android.okhttp.Cache$1.put(Cache.java:142)
at com.android.okhttp.internal.http.HttpEngine.maybeCache(HttpEngine.java:547)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:821)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:463)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:405)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:521)
at com.squareup.picasso.UrlConnectionDownloader.load(UrlConnectionDownloader.java:93)
at com.squareup.picasso.NetworkRequestHandler.load(NetworkRequestHandler.java:47)
at com.squareup.picasso.BitmapHunter.hunt(BitmapHunter.java:206)
at com.squareup.picasso.BitmapHunter.run(BitmapHunter.java:159)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:428)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:607)
at java.lang.Thread.run(Thread.java:761)
at com.squareup.picasso.Utils$PicassoThread.run(Utils.java:411)
i have the same issue to.
when i make minifyEnabled false the error it's not gonna happen again :|
and i have the proguard rules but it seems they not working
-keepattributes Signature
-keepattributes Annotation
-keep class okhttp3.* { *; }
-keep interface okhttp3.* { ; }
-dontwarn okhttp3.*
-dontwarn okio.**
and i need minyfyEnabled
then can any body tell me what i have to do ?
whats the problem ? whats are the rules i need ?
Most helpful comment
I have the same problem,I have the same problem, using 'com.squareup.okhttp3:okhttp:3.2.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 java.io.FileInputStream.<init>(FileInputStream.java:78) at okio.Okio.source(Okio.java:168) at okhttp3.internal.io.FileSystem$1.source(FileSystem.java:44) at okhttp3.internal.DiskLruCache$Entry.snapshot(DiskLruCache.java:1040) at okhttp3.internal.DiskLruCache.get(DiskLruCache.java:436) at okhttp3.Cache.get(Cache.java:193) at okhttp3.Cache$1.get(Cache.java:143) at okhttp3.internal.http.HttpEngine.sendRequest(HttpEngine.java:203) at okhttp3.RealCall.getResponse(RealCall.java:243) at okhttp3.RealCall$ApplicationInterceptorChain.proceed(RealCall.java:201) at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:163) at okhttp3.RealCall.access$100(RealCall.java:30) at okhttp3.RealCall$AsyncCall.execute(RealCall.java:127) at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)