diff options
author | Vasu Nori <vnori@google.com> | 2010-03-03 10:05:16 -0800 |
---|---|---|
committer | Vasu Nori <vnori@google.com> | 2010-03-03 10:05:16 -0800 |
commit | 08b448ea39e9fabfc5212ae6f7226eba4385d189 (patch) | |
tree | 76e0402f0de4d4ea4f1ddcab36de4930755c8b71 /core/java/android/database | |
parent | 687c44f2f02cecc4103c611ead225f990402d1af (diff) | |
download | frameworks_base-08b448ea39e9fabfc5212ae6f7226eba4385d189.zip frameworks_base-08b448ea39e9fabfc5212ae6f7226eba4385d189.tar.gz frameworks_base-08b448ea39e9fabfc5212ae6f7226eba4385d189.tar.bz2 |
in finalizer warnings, use a better exception - NOT Exception()
finalizer warnings should use a more descriptive exception instead of
Exception() so it is clearer to the developers as to why this
warning is output.
Diffstat (limited to 'core/java/android/database')
4 files changed, 35 insertions, 3 deletions
diff --git a/core/java/android/database/sqlite/DatabaseObjectNotClosedException.java b/core/java/android/database/sqlite/DatabaseObjectNotClosedException.java new file mode 100644 index 0000000..9fe1f54 --- /dev/null +++ b/core/java/android/database/sqlite/DatabaseObjectNotClosedException.java @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2006 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.database.sqlite; + +/** + * An exception that indicates that garbage-collector is finalizing a database object + * that is not explicitly closed + */ +public class DatabaseObjectNotClosedException extends RuntimeException +{ + private static final String s = "Application did not close the cursor or database object " + + "that was opened here"; + + public DatabaseObjectNotClosedException() + { + super(s); + } +} diff --git a/core/java/android/database/sqlite/SQLiteCompiledSql.java b/core/java/android/database/sqlite/SQLiteCompiledSql.java index 486ad20..4ccf6b0 100644 --- a/core/java/android/database/sqlite/SQLiteCompiledSql.java +++ b/core/java/android/database/sqlite/SQLiteCompiledSql.java @@ -56,7 +56,7 @@ import android.util.Log; /* package */ SQLiteCompiledSql(SQLiteDatabase db, String sql) { mDatabase = db; mSqlStmt = sql; - mStackTrace = new Exception().fillInStackTrace(); + mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); this.nHandle = db.mNativeHandle; compile(sql, true); } diff --git a/core/java/android/database/sqlite/SQLiteCursor.java b/core/java/android/database/sqlite/SQLiteCursor.java index 96ed297..3f0fcb1 100644 --- a/core/java/android/database/sqlite/SQLiteCursor.java +++ b/core/java/android/database/sqlite/SQLiteCursor.java @@ -207,7 +207,7 @@ public class SQLiteCursor extends AbstractWindowedCursor { String editTable, SQLiteQuery query) { // The AbstractCursor constructor needs to do some setup. super(); - mStackTrace = new Exception().fillInStackTrace(); + mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); mDatabase = db; mDriver = driver; mEditTable = editTable; diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java index d8ccf85..9fa9368 100644 --- a/core/java/android/database/sqlite/SQLiteDatabase.java +++ b/core/java/android/database/sqlite/SQLiteDatabase.java @@ -1749,7 +1749,7 @@ public class SQLiteDatabase extends SQLiteClosable { mFlags = flags; mPath = path; mSlowQueryThreshold = SystemProperties.getInt(LOG_SLOW_QUERIES_PROPERTY, -1); - mStackTrace = new Exception().fillInStackTrace(); + mStackTrace = new DatabaseObjectNotClosedException().fillInStackTrace(); mFactory = factory; dbopen(mPath, mFlags); if (SQLiteDebug.DEBUG_SQL_CACHE) { |