-
-
Notifications
You must be signed in to change notification settings - Fork 64
Closed
Description
While testing with an emulator running api31, this logcat warning appears numerous times after adding or reconfiguring a widget.
W/System: A resource failed to call close.
It turns out the warning can be turned into an exception.. (from stackoverflow)
try {
Class.forName("dalvik.system.CloseGuard").getMethod("setEnabled", boolean.class).invoke(null, true);
} catch (ReflectiveOperationException e) {
throw new RuntimeException(e);
}
which produces:
2022-01-11 22:53:02.933 4195-4206/com.forrestguice.suntimeswidget 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 android.database.CursorWindow.finalize(CursorWindow.java:181)
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 'close' not called
at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:295)
at dalvik.system.CloseGuard.open(CloseGuard.java:263)
at android.database.CursorWindow.<init>(CursorWindow.java:145)
at android.database.CursorWindow.<init>(CursorWindow.java:122)
at android.database.AbstractWindowedCursor.clearOrCreateWindow(AbstractWindowedCursor.java:203)
at android.database.sqlite.SQLiteCursor.fillWindow(SQLiteCursor.java:139)
at android.database.sqlite.SQLiteCursor.getCount(SQLiteCursor.java:132)
at android.database.AbstractCursor.moveToPosition(AbstractCursor.java:238)
at android.database.AbstractCursor.moveToFirst(AbstractCursor.java:277)
at com.forrestguice.suntimeswidget.getfix.GetFixDatabaseAdapter.getPlace(GetFixDatabaseAdapter.java:161)
at com.forrestguice.suntimeswidget.getfix.LocationListTask.doInBackground(LocationListTask.java:57)
at com.forrestguice.suntimeswidget.getfix.LocationListTask.doInBackground(LocationListTask.java:29)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
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)
and
2022-01-11 23:28:33.889 4692-4703/com.forrestguice.suntimeswidget 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 android.database.AbstractCursor.finalize(AbstractCursor.java:531)
at android.database.sqlite.SQLiteCursor.finalize(SQLiteCursor.java:291)
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 'close' not called
at dalvik.system.CloseGuard.openWithCallSite(CloseGuard.java:295)
at dalvik.system.CloseGuard.open(CloseGuard.java:263)
at android.database.AbstractCursor.<init>(AbstractCursor.java:227)
at android.database.AbstractWindowedCursor.<init>(AbstractWindowedCursor.java:39)
at android.database.sqlite.SQLiteCursor.<init>(SQLiteCursor.java:98)
at android.database.sqlite.SQLiteDirectCursorDriver.query(SQLiteDirectCursorDriver.java:52)
at android.database.sqlite.SQLiteDatabase.rawQueryWithFactory(SQLiteDatabase.java:1546)
at android.database.sqlite.SQLiteDatabase.queryWithFactory(SQLiteDatabase.java:1393)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1264)
at android.database.sqlite.SQLiteDatabase.query(SQLiteDatabase.java:1432)
at com.forrestguice.suntimeswidget.getfix.GetFixDatabaseAdapter.getAllPlaces(GetFixDatabaseAdapter.java:125)
at com.forrestguice.suntimeswidget.getfix.LocationListTask.doInBackground(LocationListTask.java:49)
at com.forrestguice.suntimeswidget.getfix.LocationListTask.doInBackground(LocationListTask.java:29)
at android.os.AsyncTask$3.call(AsyncTask.java:394)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:305)
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)