diff options
Diffstat (limited to 'core/java')
-rw-r--r-- | core/java/android/database/sqlite/SQLiteCompiledSql.java | 10 | ||||
-rw-r--r-- | core/java/android/database/sqlite/SQLiteCursor.java | 8 |
2 files changed, 13 insertions, 5 deletions
diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java index bdb96b1..dafbc79 100644 --- a/core/java/android/database/sqlite/SQLiteCompiledSql.java +++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java @@ -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; - mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); + 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 " + diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java index 9574300..c24acd4 100644 --- a/core/java/android/database/sqlite/SQLiteCursor.java +++ b/core/java/android/database/sqlite/SQLiteCursor.java @@ -95,7 +95,11 @@ public class SQLiteCursor extends AbstractWindowedCursor { if (query.mDatabase == null) { throw new IllegalArgumentException("query.mDatabase cannot be null"); } - mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); + 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. " + |