Loading core/java/android/database/sqlite/SQLiteClosable.java +24 −2 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.database.sqlite; package android.database.sqlite; import android.database.CursorWindow; /** /** * An object create from a SQLiteDatabase that can be closed. * An object create from a SQLiteDatabase that can be closed. */ */ Loading @@ -29,7 +31,7 @@ public abstract class SQLiteClosable { synchronized(mLock) { synchronized(mLock) { if (mReferenceCount <= 0) { if (mReferenceCount <= 0) { throw new IllegalStateException( 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++; } } Loading @@ -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(); } } } Loading
core/java/android/database/sqlite/SQLiteClosable.java +24 −2 Original line number Original line Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.database.sqlite; package android.database.sqlite; import android.database.CursorWindow; /** /** * An object create from a SQLiteDatabase that can be closed. * An object create from a SQLiteDatabase that can be closed. */ */ Loading @@ -29,7 +31,7 @@ public abstract class SQLiteClosable { synchronized(mLock) { synchronized(mLock) { if (mReferenceCount <= 0) { if (mReferenceCount <= 0) { throw new IllegalStateException( 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++; } } Loading @@ -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(); } } }