Open charles-hennge opened 3 years ago
Follow up:
It looks like the get() call in fetch here generates an HttpResponse object that needs to be closed after parsing the its content into a string.
Thank you. But it doesn't reproduce in my environment. And I don't think there's anything wrong with the part you pointed out. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.io/use.html
Does it happen on any device? Please tell me the OS version and device name that occur Does it occur at any URL? Please tell me the URL that occur
Hello, sorry for the late reply.
I tried to build a small sample app that demonstrates the problem but I am unable to find sample links that actually detect as having favicon/touch icons.
On further checking of the issue when it occurs inside of my code, it appears that its related to running TouchIconExtractor.fromPage() on multiple URLs in succession. It looks like users need to prevent concurrent execution of this particular method. That might be worth putting in the documentation if its not already there.
First of all, I want you to provide information that can be reproduced.
When using TouchIconExtractor with a url under strict mode, it appears that a closable resource (a GzipSource?, HTTPURLConnection?) is not being properly closed and is potentially leaking.
Example Code:
Example Crash Log: StrictMode: StrictMode policy violation: android.os.strictmode.LeakedClosableViolation: A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks. at android.os.StrictMode$AndroidCloseGuardReporter.report(StrictMode.java:1877) at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:286) at java.util.zip.Inflater.finalize(Inflater.java:407) at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:289) at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:276) at java.lang.Daemons$Daemon.run(Daemons.java:137) at java.lang.Thread.run(Thread.java:919) Caused by: java.lang.Throwable: Explicit termination method 'end' not called at dalvik.system.CloseGuard.open(CloseGuard.java:237) at java.util.zip.Inflater.(Inflater.java:122)
at com.android.okhttp.okio.GzipSource.(GzipSource.java:64)
at com.android.okhttp.internal.http.HttpEngine.unzip(HttpEngine.java:484)
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:661)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:542)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getResponseCode(DelegatingHttpsURLConnection.java:106)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:30)
at oj0.(SimpleHttpResponse.kt:18)
at mj0.a(SimpleHttpClientAdapter.kt:31)
at yi0.f(ExtractFromPage.kt:44)
at yi0.g(ExtractFromPage.kt:25)
at ej0.a(TouchIconExtractor.kt:79)