Merge "add diagnostic info to help debug bug:2427686"

This commit is contained in:
Vasu Nori
2010-02-18 16:43:14 -08:00
committed by Android (Google) Code Review

View File

@@ -16,6 +16,8 @@
package android.database.sqlite;
import android.database.CursorWindow;
/**
* An object create from a SQLiteDatabase that can be closed.
*/
@@ -29,9 +31,9 @@ public abstract class SQLiteClosable {
synchronized(mLock) {
if (mReferenceCount <= 0) {
throw new IllegalStateException(
"attempt to acquire a reference on an already-closed SQLiteClosable obj.");
"attempt to acquire a reference on an already-closed " + getObjInfo());
}
mReferenceCount++;
mReferenceCount++;
}
}
@@ -52,4 +54,24 @@ public abstract class SQLiteClosable {
}
}
}
private String getObjInfo() {
StringBuilder buff = new StringBuilder();
buff.append(this.getClass().getName());
buff.append(" Obj");
buff.append(" (");
if (this instanceof SQLiteDatabase) {
buff.append("database = ");
buff.append(((SQLiteDatabase)this).getPath());
} else if (this instanceof SQLiteProgram || this instanceof SQLiteStatement ||
this instanceof SQLiteQuery) {
buff.append("mSql = ");
buff.append(((SQLiteProgram)this).mSql);
} else if (this instanceof CursorWindow) {
buff.append("mStartPos = ");
buff.append(((CursorWindow)this).getStartPosition());
}
buff.append(") ");
return buff.toString();
}
}