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

LeakedClosableViolation #318

Closed
Pitel opened this issue Apr 7, 2020 · 1 comment
Closed

LeakedClosableViolation #318

Pitel opened this issue Apr 7, 2020 · 1 comment

Comments

@Pitel
Copy link

Pitel commented Apr 7, 2020

✍️ Describe the bug

When strict mode is enabled, it complains some resource is not closed by Chucker

💣 Steps to reproduce

  1. Enable StricMode
    StrictMode.setThreadPolicy(
        StrictMode.ThreadPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .build()
        )
    StrictMode.setVmPolicy(
        StrictMode.VmPolicy.Builder()
            .detectAll()
            .penaltyLog()
            .build()
        )
  2. Use Chucker as usual, do some HTTP requests, watch Logcat.
  3. Notice StrictMode policy violation in Logcat

🔧 Expected behavior

No StrictMode policy violations.

📷 Screenshots

2020-04-07 09:26:34.245 21511-21534 D/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.io.FileInputStream.finalize(FileInputStream.java:493)
        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 'close' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:237)
        at java.io.FileInputStream.<init>(FileInputStream.java:174)
        at okio.Okio.source(Okio.kt:184)
        at com.chuckerteam.chucker.api.ChuckerInterceptor$ChuckerTransactionTeeCallback.readResponseBuffer(ChuckerInterceptor.kt:251)
        at com.chuckerteam.chucker.api.ChuckerInterceptor$ChuckerTransactionTeeCallback.onSuccess(ChuckerInterceptor.kt:239)
        at com.chuckerteam.chucker.internal.support.TeeSource.close(TeeSource.kt:69)
        at okio.RealBufferedSource.close(RealBufferedSource.kt:498)
        at okhttp3.internal.Util.closeQuietly(Util.kt:488)
        at okhttp3.ResponseBody.close(ResponseBody.kt:192)
        at retrofit2.OkHttpCall$ExceptionCatchingResponseBody.close(OkHttpCall.java:310)
        at retrofit2.BuiltInConverters$UnitResponseBodyConverter.convert(BuiltInConverters.java:74)
        at retrofit2.BuiltInConverters$UnitResponseBodyConverter.convert(BuiltInConverters.java:70)
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:225)
        at retrofit2.OkHttpCall$1.onResponse(OkHttpCall.java:121)
        at okhttp3.internal.connection.RealCall$AsyncCall.run(RealCall.kt:504)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:919) 

📱 Tech info

  • Device: Pixel 3a
  • OS: 10
  • Chucker version: 3.2.0

📄 Additional context

Chucker 3.1 was ok.

@vbuberen
Copy link
Collaborator

vbuberen commented Apr 7, 2020

Thanks for reporting this issue.
It was reported yesterday and already fixed by #316.
Feel free to switch to develop snapshot which has this fix along with some other minor UI fixes.

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

No branches or pull requests

2 participants