Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 42960e8d authored by Vasu Nori's avatar Vasu Nori
Browse files

when finalizing SQLiteCursor, close it but don't throw exceptions.

currently, an exception is thrown if SQLiteCursor object is being
finalized before the cursor is closed. instead of an exception, simply
log an error message.
some android team members look at the exception and think it is catastrophic.
parent a3452ad9
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -582,21 +582,23 @@ public class SQLiteCursor extends AbstractWindowedCursor {
    @Override
    protected void finalize() {
        try {
            // if the cursor hasn't been closed yet, close it first
            if (mWindow != null) {
                close();
                String message = "Finalizing cursor " + this + " on " + mEditTable
                        + " that has not been deactivated or closed";
                Log.e(TAG, "Finalizing cursor that has not been deactivated or closed." 
                    + " database = " + mDatabase.getPath() + ", table = " + mEditTable
                    + ", query = " + mQuery.mSql);
                if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
                    Log.d(TAG, message + "\nThis cursor was created in:");
                    Log.d(TAG, "This cursor was created in:");
                    for (StackTraceElement ste : mStackTraceElements) {
                        Log.d(TAG, "      " + ste);
                    }
                }
                SQLiteDebug.notifyActiveCursorFinalized();
                throw new IllegalStateException(message);
            } else {
                if (Config.LOGV) {
                    Log.v(TAG, "Finalizing cursor " + this + " on " + mEditTable);
                    Log.v(TAG, "Finalizing cursor on database = " + mDatabase.getPath() +
                            ", table = " + mEditTable + ", query = " + mQuery.mSql);
                }
            }
        } finally {