remove some useless code and add some code to aid in debugging
Change-Id: Ie532848b82dde57cc7a7017661679ece06ca606e
This commit is contained in:
@@ -30,6 +30,7 @@ public abstract class SQLiteClosable {
|
||||
|
||||
public void acquireReference() {
|
||||
synchronized(mLock) {
|
||||
checkRefCount();
|
||||
if (mReferenceCount <= 0) {
|
||||
throw new IllegalStateException(
|
||||
"attempt to re-open an already-closed object: " + getObjInfo());
|
||||
@@ -40,6 +41,7 @@ public abstract class SQLiteClosable {
|
||||
|
||||
public void releaseReference() {
|
||||
synchronized(mLock) {
|
||||
checkRefCount();
|
||||
mReferenceCount--;
|
||||
if (mReferenceCount == 0) {
|
||||
onAllReferencesReleased();
|
||||
@@ -49,6 +51,7 @@ public abstract class SQLiteClosable {
|
||||
|
||||
public void releaseReferenceFromContainer() {
|
||||
synchronized(mLock) {
|
||||
checkRefCount();
|
||||
mReferenceCount--;
|
||||
if (mReferenceCount == 0) {
|
||||
onAllReferencesReleasedFromContainer();
|
||||
@@ -63,8 +66,7 @@ public abstract class SQLiteClosable {
|
||||
if (this instanceof SQLiteDatabase) {
|
||||
buff.append("database = ");
|
||||
buff.append(((SQLiteDatabase)this).getPath());
|
||||
} else if (this instanceof SQLiteProgram || this instanceof SQLiteStatement ||
|
||||
this instanceof SQLiteQuery) {
|
||||
} else if (this instanceof SQLiteProgram) {
|
||||
buff.append("mSql = ");
|
||||
buff.append(((SQLiteProgram)this).mSql);
|
||||
} else if (this instanceof CursorWindow) {
|
||||
@@ -74,4 +76,13 @@ public abstract class SQLiteClosable {
|
||||
buff.append(") ");
|
||||
return buff.toString();
|
||||
}
|
||||
|
||||
private void checkRefCount() {
|
||||
if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
|
||||
if (mReferenceCount > 1000) {
|
||||
throw new IllegalStateException("refcount: " + mReferenceCount + ", " +
|
||||
getObjInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,9 +92,6 @@ import android.util.Log;
|
||||
// Note that native_finalize() checks to make sure that nStatement is
|
||||
// non-null before destroying it.
|
||||
if (nStatement != 0) {
|
||||
if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
|
||||
Log.v(TAG, "closed and deallocated DbObj (id#" + nStatement +")");
|
||||
}
|
||||
mDatabase.finalizeStatementLater(nStatement);
|
||||
nStatement = 0;
|
||||
}
|
||||
@@ -109,16 +106,10 @@ import android.util.Log;
|
||||
return false;
|
||||
}
|
||||
mInUse = true;
|
||||
if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
|
||||
Log.v(TAG, "Acquired DbObj (id#" + nStatement + ") from DB cache");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* package */ synchronized void release() {
|
||||
if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
|
||||
Log.v(TAG, "Released DbObj (id#" + nStatement + ") back to DB cache");
|
||||
}
|
||||
mInUse = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -130,10 +130,6 @@ public abstract class SQLiteProgram extends SQLiteClosable {
|
||||
// make sure it is acquired by me.
|
||||
mCompiledSql.acquire();
|
||||
mDatabase.addToCompiledQueries(mSql, mCompiledSql);
|
||||
if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
|
||||
Log.v(TAG, "Created DbObj (id#" + mCompiledSql.nStatement +
|
||||
") for sql: " + mSql);
|
||||
}
|
||||
} else {
|
||||
// it is already in compiled-sql cache.
|
||||
// try to acquire the object.
|
||||
@@ -144,12 +140,6 @@ public abstract class SQLiteProgram extends SQLiteClosable {
|
||||
// CompiledSql object. create a new one.
|
||||
// finalize it when I am done with it in "this" object.
|
||||
mCompiledSql = new SQLiteCompiledSql(mDatabase, mSql);
|
||||
if (SQLiteDebug.DEBUG_ACTIVE_CURSOR_FINALIZATION) {
|
||||
Log.v(TAG, "** possible bug ** Created NEW DbObj (id#" +
|
||||
mCompiledSql.nStatement +
|
||||
") because the previously created DbObj (id#" + last +
|
||||
") was not released for sql:" + mSql);
|
||||
}
|
||||
// since it is not in the cache, no need to acquire() it.
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user