Gander icon indicating copy to clipboard operation
Gander copied to clipboard

Strict mode warnings

Open amitav13 opened this issue 5 years ago • 1 comments

Hi, I've recently switched on Strict mode in my app with these settings:

if (BuildConfig.DEBUG) {
        StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder()
            .detectDiskReads()
            .detectDiskWrites()
            .detectNetwork()
            .build())

        StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder()
            .detectLeakedSqlLiteObjects()
            .detectLeakedClosableObjects()
            .penaltyLog()
            .build())
    }

And I've been getting spammed with this stacktrace since:

2019-06-27 18:28:00.663 13773-13780/com.buyceps.kiosk 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 'end' not called
        at dalvik.system.CloseGuard.open(CloseGuard.java:180)
        at java.util.zip.Inflater.<init>(Inflater.java:104)
        at okio.GzipSource.<init>(GzipSource.java:62)
        at com.ashokvarma.gander.GanderInterceptor.getNativeSource(GanderInterceptor.java:358)
        at com.ashokvarma.gander.GanderInterceptor.getNativeSource(GanderInterceptor.java:370)
        at com.ashokvarma.gander.GanderInterceptor.updateTransactionFromResponse(GanderInterceptor.java:248)
        at com.ashokvarma.gander.GanderInterceptor.intercept(GanderInterceptor.java:160)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:45)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.java:225)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at com.valartech.commons.network.retrofit.AuthHeaderInterceptor.intercept(AuthHeaderInterceptor.kt:32)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
        at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:250)
        at okhttp3.RealCall$AsyncCall.execute(RealCall.java:201)
        at okhttp3.internal.NamedRunnable.run(NamedRunnable.java:32)
        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)

The offending line seems to be this one in GanderInterceptor.java:

@NonNull
    private BufferedSource getNativeSource(@NonNull BufferedSource input, boolean isGzipped) {
        if (isGzipped) {
            GzipSource source = new GzipSource(input); //this one
            return Okio.buffer(source);
        } else {
            return input;
        }
    }

amitav13 avatar Jun 27 '19 13:06 amitav13

Hi @amitav13 thanks for the report we will look in to this asap

Ashok-Varma avatar Jun 28 '19 15:06 Ashok-Varma