Glide Version: 4.3.1
Integration libraries:
Device/Android Version: Pixel Android 8.1
Issue details / Repro steps / Use case background:
I'm using gravatar to get the icon for an app, sometimes the user won't have a gravatar profile and that's ok, I just don't show it; however when that happens it seems that Glide doesn't closes the response body.
Glide load line / GlideModule (if any) / list Adapter code (if any):
Glide.with(context)
.asBitmap()
.load(gravatarURL)
.into(object : SimpleTarget<Bitmap>() {
override fun onResourceReady(resource: Bitmap, glideAnimation: Transition<in Bitmap>) {
callback.onImageAvailable(resource)
}
override fun onLoadFailed(errorDrawable: Drawable?) {
// nothing expected
}
})
Layout XML:
Irrelevant for this case
Stack trace / LogCat:
Root cause (1 of 1)
java.io.FileNotFoundException: https://www.gravatar.com/avatar/abc.jpg?s=96&d=404&r=g
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getInputStream(DelegatingHttpsURLConnection.java:210)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getInputStream(Unknown Source:0)
at com.android.tools.profiler.support.network.httpurl.TrackedHttpURLConnection.getInputStream(TrackedHttpURLConnection.java:356)
at com.android.tools.profiler.support.network.httpurl.HttpsURLConnection$.getInputStream(HttpsURLConnection$.java:261)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:104)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:54)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:96)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:147)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:141)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:60)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:96)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:61)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:298)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:268)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:229)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:413)
01-14 18:58:38.279 16938-17139/ W/OkHttpClient: A connection to https://www.gravatar.com/ was leaked. Did you forget to close a response body?
If you try the OkHttp integration library do you see the same issue? http://bumptech.github.io/glide/int/okhttp3.html. I'd guess this either an issue with how we clean up HttpUrlConnections or a platform issue since we're not actually using OkHttp directly.
I have the same warning
01-17 11:02:35.532 19466-19466/com.package.xx W/Glide: Load failed for http://host.domain.de/path/to/image/image.jpg with size [320x320]
class com.bumptech.glide.load.engine.GlideException: Failed to load resource
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetching data failed, class java.io.InputStream, REMOTE
Cause (1 of 1): class com.bumptech.glide.load.engine.GlideException: Fetch failed
Cause (1 of 1): class java.io.FileNotFoundException: http://host.domain.de/path/to/image/image.jpg
01-17 11:02:38.213 19466-19577/com.package.xx W/OkHttpClient: A connection to http://host.domain.de/ was leaked. Did you forget to close a response body?
01-17 11:02:38.214 19466-19577/com.package.xx W/OkHttpClient: A connection to http://host.domain.de/ was leaked. Did you forget to close a response body?
I bumped up my glide version from 4.3.1 to 4.5.0 and the issue is now gone. If I go back I'm still getting the warning. It seems the OkHttp integration library doesn't actually make a difference for this issue. In my case updating wasn't a problem so I'll use the latest.
Thanks.
Thanks @rcgonzalezf.
@skauss what version of Glide are you using?
I use the Glide Version 4.3.1
Ok let's assume this is fixed in 4.5.0. If someone can reproduce on 4.5.0 or higher please let me know.
Hi,
today I found the Warning of the OkHttpClient again.
The version of Glide is 4.5.0 and the OkHttpClient is 3.9.1
W/OkHttpClient: A connection to http://host.domain.xx/ was leaked. Did you forget to close a response body?
It occur only some times in the case I have a FileNotFoundException
Some times mean 6 times file not found and 2 times OkHttpClient: A connection to xx was leaked
java.io.FileNotFoundException: http://host.domain.xx/theImage.jpg
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getInputStream(HttpURLConnectionImpl.java:251)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadDataWithRedirects(HttpUrlFetcher.java:106)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:59)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:97)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.startNextOrFail(MultiModelLoader.java:148)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.onLoadFailed(MultiModelLoader.java:142)
at com.bumptech.glide.load.data.HttpUrlFetcher.loadData(HttpUrlFetcher.java:65)
at com.bumptech.glide.load.model.MultiModelLoader$MultiFetcher.loadData(MultiModelLoader.java:97)
at com.bumptech.glide.load.engine.SourceGenerator.startNext(SourceGenerator.java:62)
at com.bumptech.glide.load.engine.DecodeJob.runGenerators(DecodeJob.java:299)
at com.bumptech.glide.load.engine.DecodeJob.runWrapped(DecodeJob.java:269)
at com.bumptech.glide.load.engine.DecodeJob.run(DecodeJob.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
at java.lang.Thread.run(Thread.java:764)
at com.bumptech.glide.load.engine.executor.GlideExecutor$DefaultThreadFactory$1.run(GlideExecutor.java:446)
Regards
Same issue here when I have a FileNotFoundException.
Glide version: 4.7.1
Android version: 8.1 (API 27)
Same here, also on 4.7.1.
What versions of Android are you seeing this message on?
I use now Glide 4.8.0 on Android 7.1 / Android 9.0 and is seems the problem is solved.
I am using glide 4.9.0 and glide:compiler:4.9.0. and got W/OkHttpClient: A connection to http://test-api.heitouyang.cn/ was leaked. Did you forget to close a response body? after the image not found.
How can I solve this.
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
the android version is 8.1.0 api 27 and it is an oppo pbam00 android phone device
Most helpful comment
Same issue here when I have a FileNotFoundException.
Glide version: 4.7.1
Android version: 8.1 (API 27)