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

Commit 7978a414 authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Only populate stack when StrictMode will use it.

When the StrictMode VM flag is changed mid-lifecycle, pass along at
least a basic trace.

Bug: 5516561
Change-Id: I6c922ba20f34349c35624cfc04d1c71ee56ad6ef
parent 6e03b220
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ import android.util.Log;

    /** the following are for debugging purposes */
    private String mSqlStmt = null;
    private Throwable mStackTrace = null;
    private final Throwable mStackTrace;

    /** when in cache and is in use, this member is set */
    private boolean mInUse = false;
@@ -59,7 +59,11 @@ import android.util.Log;
        db.verifyLockOwner();
        mDatabase = db;
        mSqlStmt = sql;
        if (StrictMode.vmSqliteObjectLeaksEnabled()) {
            mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
        } else {
            mStackTrace = null;
        }
        nHandle = db.mNativeHandle;
        native_compile(sql);
    }
@@ -112,7 +116,7 @@ import android.util.Log;
            // 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.
            // in that case, don't print any warning.
            if (mInUse && StrictMode.vmSqliteObjectLeaksEnabled()) {
            if (mInUse && mStackTrace != null) {
                int len = mSqlStmt.length();
                StrictMode.onSqliteObjectLeaked(
                    "Releasing statement in a finalizer. Please ensure " +
+6 −2
Original line number Diff line number Diff line
@@ -95,7 +95,11 @@ public class SQLiteCursor extends AbstractWindowedCursor {
        if (query.mDatabase == null) {
            throw new IllegalArgumentException("query.mDatabase cannot be null");
        }
        if (StrictMode.vmSqliteObjectLeaksEnabled()) {
            mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace();
        } else {
            mStackTrace = null;
        }
        mDriver = driver;
        mEditTable = editTable;
        mColumnNameMap = null;
@@ -319,7 +323,7 @@ public class SQLiteCursor extends AbstractWindowedCursor {
        try {
            // if the cursor hasn't been closed yet, close it first
            if (mWindow != null) {
                if (StrictMode.vmSqliteObjectLeaksEnabled()) {
                if (mStackTrace != null) {
                    int len = mQuery.mSql.length();
                    StrictMode.onSqliteObjectLeaked(
                        "Finalizing a Cursor that has not been deactivated or closed. " +