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

Commit 4b91b4b1 authored by Vasu Nori's avatar Vasu Nori Committed by Android (Google) Code Review
Browse files

Merge "bug:3385018 don't print finalizer warnings under certain conditions"

parents 81997413 83ff97d8
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -103,6 +103,11 @@ import android.util.Log;
    protected void finalize() throws Throwable {
        try {
            if (nStatement == 0) return;
            // don't worry about finalizing this object if it is ALREADY in the
            // queue of statements to be finalized later
            if (mDatabase.isInQueueOfStatementsToBeFinalized(nStatement)) {
                return;
            }
            // finalizer should NEVER get called
            // but if the database itself is not closed and is GC'ed, then
            // all sub-objects attached to the database could end up getting GC'ed too.
+11 −0
Original line number Diff line number Diff line
@@ -2274,6 +2274,17 @@ public class SQLiteDatabase extends SQLiteClosable {
        }
    }

    /* package */ boolean isInQueueOfStatementsToBeFinalized(int id) {
        if (!isOpen()) {
            // database already closed. this statement will already have been finalized.
            // return true so that the caller doesn't have to worry about finalizing this statement.
            return true;
        }
        synchronized(mClosedStatementIds) {
            return mClosedStatementIds.contains(id);
        }
    }

    /* package */ void closePendingStatements() {
        if (!isOpen()) {
            // since this database is already closed, no need to finalize anything.