optimizely / android-sdk

Android SDK for Optimizely Feature Experimentation and Optimizely Full Stack (legacy)
https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/android-sdk
Apache License 2.0
55 stars 39 forks source link

StrictMode violation due to Deflater.end() not being called #419

Closed schmecs closed 2 years ago

schmecs commented 2 years ago

Minor / no obvious effect on performance. EventHandlerUtils isn't calling end() on its deflater when finished which causes a StrictMode violation.

See logs:

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:1987)
        at dalvik.system.CloseGuard.warnIfOpen(CloseGuard.java:345)
        at java.util.zip.Deflater.finalize(Deflater.java:575)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:291)
        at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:278)
        at java.lang.Daemons$Daemon.run(Daemons.java:139)
        at java.lang.Thread.run(Thread.java:920)
     Caused by: java.lang.Throwable: Explicit termination method 'end' not called
        at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:295)
        at dalvik.system.CloseGuard.open(CloseGuard.java:263)
        at java.util.zip.Deflater.<init>(Deflater.java:189)
        at java.util.zip.Deflater.<init>(Deflater.java:206)
        at com.optimizely.ab.android.event_handler.EventHandlerUtils.compress(EventHandlerUtils.java:30)
        at com.optimizely.ab.android.event_handler.EventWorker.compressEvent(EventWorker.java:114)
        at com.optimizely.ab.android.event_handler.EventWorker.getData(EventWorker.java:94)
        at com.optimizely.ab.android.event_handler.EventWorker.getData(EventWorker.java:100)
        at com.optimizely.ab.android.event_handler.DefaultEventHandler.dispatchEvent(DefaultEventHandler.java:99)
        at com.optimizely.ab.event.BatchEventProcessor$EventConsumer.flush(BatchEventProcessor.java:226)
        at com.optimizely.ab.event.BatchEventProcessor$EventConsumer.addToBatch(BatchEventProcessor.java:189)
        at com.optimizely.ab.event.BatchEventProcessor$EventConsumer.run(BatchEventProcessor.java:164)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:462)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        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:920) 
jaeopt commented 2 years ago

@schmecs Thanks. We'll take a look.