summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVasu Nori <vnori@google.com>2011-01-30 12:47:55 -0800
committerVasu Nori <vnori@google.com>2011-01-30 14:42:36 -0800
commit83ff97d8403db4d8d0a351031f0c9efcb602a99c (patch)
treee90f82b37c413da49f2c289e7f8fa6e3766bc836
parent4651e84411d3963c9b372f518c6b72adba3dec9f (diff)
downloadframeworks_base-83ff97d8403db4d8d0a351031f0c9efcb602a99c.zip
frameworks_base-83ff97d8403db4d8d0a351031f0c9efcb602a99c.tar.gz
frameworks_base-83ff97d8403db4d8d0a351031f0c9efcb602a99c.tar.bz2
bug:3385018 don't print finalizer warnings under certain conditions
Change-Id: I06c49a464f61c26d3e6645a95f2dd38d444bf384
-rw-r--r--core/java/android/database/sqlite/SQLiteCompiledSql.java5
-rw-r--r--core/java/android/database/sqlite/SQLiteDatabase.java11
2 files changed, 16 insertions, 0 deletions
diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java
index feea47e..bdb96b1 100644
--- a/core/java/android/database/sqlite/SQLiteCompiledSql.java
+++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java
@@ -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.
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index b3fd914..8c5483f 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -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.