Chasing origin of LeakedCloseableViolation in Android

Viewed 11

I've spend a day and an half now trying to chase the origin of a LeakedCloseableViolation in my app, developed to target API v32.

I have enabled strict mode with:

StrictMode.setVmPolicy( new StrictMode.VmPolicy.Builder()
  .detectLeakedClosableObjects()
  .penaltyListener( this.getMainExecutor(), ( Violation v ) -> {
    v.fillInStackTrace();
    v.printStackTrace();
  } )
  .build());

And in LogCat I get

W/System.err: 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. Callsite: close
W/System.err:     at com.wattthis.reflowmate.App.lambda$onCreate$0(App.java:30)
W/System.err:     at com.wattthis.reflowmate.App$$ExternalSyntheticLambda0.onVmViolation(Unknown Source:0)
W/System.err:     at android.os.StrictMode.lambda$onVmPolicyViolation$3(StrictMode.java:2462)
W/System.err:     at android.os.StrictMode$$ExternalSyntheticLambda3.run(Unknown Source:4)
W/System.err:     at android.os.Handler.handleCallback(Handler.java:942)
W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:99)
W/System.err:     at android.os.Looper.loopOnce(Looper.java:201)
W/System.err:     at android.os.Looper.loop(Looper.java:288)
W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:7898)
W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
W/System.err:     at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

But I don't see any clue in the stack trace as to what the origin of the issue is.
I audited my code, and don't see any streams or observers, that are not being properly closed.

The error is perfectly reproducible.
I just open the app, and leave it open on the main Activity for 30 seconds. I don't touch the phone at all.
After 30 seconds, this error appear.

Anyone have any idea on how I can get more information about what is causing this issue?

0 Answers
Related